Skip to content

Commit

Permalink
add git ignore
Browse files Browse the repository at this point in the history
  • Loading branch information
tonywok committed Mar 12, 2012
1 parent 83d4d9a commit 4478a2a
Show file tree
Hide file tree
Showing 6 changed files with 113 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
app_key.c
config.h
13 changes: 13 additions & 0 deletions CoccoaSpotbox/ZmqDispatch.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// ZmqDispatch.h
// CoccoaSpotbox
//
// Created by Tony Schneider on 3/8/12.
// Copyright (c) 2012 Edgecase. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface ZmqDispatch : NSObject

@end
13 changes: 13 additions & 0 deletions CoccoaSpotbox/ZmqDispatch.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// ZmqDispatch.m
// CoccoaSpotbox
//
// Created by Tony Schneider on 3/8/12.
// Copyright (c) 2012 Edgecase. All rights reserved.
//

#import "ZmqDispatch.h"

@implementation ZmqDispatch

@end
39 changes: 39 additions & 0 deletions ZMQContext.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#import <Foundation/Foundation.h>
#import "ZMQSocket.h" // ZMQSocketType
#import <libkern/OSAtomic.h>

/* Special polling timeout values. */
#define ZMQPollTimeoutNever (-1)
#define ZMQPollTimeoutNow (0)

@interface ZMQContext : NSObject {
void *context;
NSMutableArray *sockets;
OSSpinLock socketsLock;
BOOL terminated;
}
+ (void)getZMQVersionMajor:(int *)major minor:(int *)minor patch:(int *)patch;

/* Polling */
// Generic poll interface.
+ (int)pollWithItems:(zmq_pollitem_t *)ioItems count:(int)itemCount
timeoutAfterUsec:(long)usec;

// Creates a ZMQContext using |threadCount| threads for I/O.
- (id)initWithIOThreads:(NSUInteger)threadCount;

- (ZMQSocket *)socketWithType:(ZMQSocketType)type;
// Sockets associated with this context.
@property(readonly, retain, NS_NONATOMIC_IPHONEONLY) NSArray *sockets;

// Closes all associated sockets.
- (void)closeSockets;

// Initiates termination. All associated sockets will be shut down.
- (void)terminate;

// YES if termination has been initiated.
// KVOable.
@property(readonly, getter=isTerminated, NS_NONATOMIC_IPHONEONLY)
BOOL terminated;
@end
3 changes: 3 additions & 0 deletions ZMQObjC.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/* Convenience header - imports all ZMQObjc headers. */
#import "ZMQContext.h"
#import "ZMQSocket.h"
43 changes: 43 additions & 0 deletions ZMQSocket.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#import <Foundation/Foundation.h>
#import <zmq.h>
@class ZMQContext;

typedef int ZMQSocketType;
typedef int ZMQSocketOption;
typedef int ZMQMessageSendFlags;
typedef int ZMQMessageReceiveFlags;

@interface ZMQSocket : NSObject {
void *socket;
ZMQContext *context; // not retained
NSString *endpoint;
ZMQSocketType type;
BOOL closed;
}
// Returns @"ZMQ_PUB" for ZMQ_PUB, for example.
+ (NSString *)nameForSocketType:(ZMQSocketType)type;

// Create a socket using -[ZMQContext socketWithType:].
@property(readonly, assign, NS_NONATOMIC_IPHONEONLY) ZMQContext *context;
@property(readonly, NS_NONATOMIC_IPHONEONLY) ZMQSocketType type;

- (void)close;
// KVOable.
@property(readonly, getter=isClosed, NS_NONATOMIC_IPHONEONLY) BOOL closed;
@property(readonly, copy, NS_NONATOMIC_IPHONEONLY) NSString *endpoint;

#pragma mark Socket Options
- (BOOL)setData:(NSData *)data forOption:(ZMQSocketOption)option;
- (NSData *)dataForOption:(ZMQSocketOption)option;

#pragma mark Endpoint Configuration
- (BOOL)bindToEndpoint:(NSString *)endpoint;
- (BOOL)connectToEndpoint:(NSString *)endpoint;

#pragma mark Communication
- (BOOL)sendData:(NSData *)messageData withFlags:(ZMQMessageSendFlags)flags;
- (NSData *)receiveDataWithFlags:(ZMQMessageReceiveFlags)flags;

#pragma mark Polling
- (void)getPollItem:(zmq_pollitem_t *)outItem forEvents:(short)events;
@end

0 comments on commit 4478a2a

Please sign in to comment.