mirror of
https://github.com/protobuf-c/protobuf-c.git
synced 2024-12-28 14:48:18 +08:00
misc
git-svn-id: https://protobuf-c.googlecode.com/svn/trunk@133 00440858-1255-0410-a3e6-75ea37f81c3a
This commit is contained in:
parent
3dbfdf90bf
commit
1f0a4127eb
@ -1,6 +1,11 @@
|
||||
/* NOTE: this may not work very well on windows, where i'm
|
||||
not sure that "SOCKETs" are allocated nicely like
|
||||
file-descriptors are */
|
||||
/* TODO:
|
||||
* * epoll() implementation
|
||||
* * kqueue() implementation
|
||||
* * windows port (yeah, right, volunteers are DEFINITELY needed for this one...)
|
||||
*/
|
||||
#include <assert.h>
|
||||
#include <alloca.h>
|
||||
#include <sys/time.h>
|
||||
|
@ -13,6 +13,12 @@ typedef enum
|
||||
PROTOBUF_C_EVENT_WRITABLE = (1<<1)
|
||||
} ProtobufC_Events;
|
||||
|
||||
#ifdef WIN32
|
||||
typedef SOCKET ProtobufC_FD;
|
||||
#else
|
||||
typedef int ProtobufC_FD;
|
||||
#endif
|
||||
|
||||
/* Create or destroy a Dispatch */
|
||||
ProtobufCDispatch *protobuf_c_dispatch_new (ProtobufCAllocator *allocator);
|
||||
void protobuf_c_dispatch_free(ProtobufCDispatch *dispatch);
|
||||
@ -21,20 +27,20 @@ ProtobufCDispatch *protobuf_c_dispatch_default (void);
|
||||
|
||||
ProtobufCAllocator *protobuf_c_dispatch_peek_allocator (ProtobufCDispatch *);
|
||||
|
||||
typedef void (*ProtobufCDispatchCallback) (int fd,
|
||||
unsigned events,
|
||||
void *callback_data);
|
||||
typedef void (*ProtobufCDispatchCallback) (ProtobufC_FD fd,
|
||||
unsigned events,
|
||||
void *callback_data);
|
||||
|
||||
/* Registering file-descriptors to watch. */
|
||||
void protobuf_c_dispatch_watch_fd (ProtobufCDispatch *dispatch,
|
||||
int fd,
|
||||
ProtobufC_FD fd,
|
||||
unsigned events,
|
||||
ProtobufCDispatchCallback callback,
|
||||
void *callback_data);
|
||||
void protobuf_c_dispatch_close_fd (ProtobufCDispatch *dispatch,
|
||||
int fd);
|
||||
ProtobufC_FD fd);
|
||||
void protobuf_c_dispatch_fd_closed(ProtobufCDispatch *dispatch,
|
||||
int fd);
|
||||
ProtobufC_FD fd);
|
||||
|
||||
/* Timers */
|
||||
typedef void (*ProtobufCDispatchTimerFunc) (ProtobufCDispatch *dispatch,
|
||||
@ -73,17 +79,17 @@ void protobuf_c_dispatch_run (ProtobufCDispatch *dispatch);
|
||||
|
||||
|
||||
/* --- API for those who want to embed a dispatch into their own main-loop --- */
|
||||
#ifdef WIN32
|
||||
typedef SOCKET ProtobufC_FD;
|
||||
#else
|
||||
typedef int ProtobufC_FD;
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
ProtobufC_FD fd;
|
||||
ProtobufC_Events events;
|
||||
} ProtobufC_FDNotify;
|
||||
|
||||
typedef struct {
|
||||
ProtobufC_FD fd;
|
||||
ProtobufC_Events old_events;
|
||||
ProtobufC_Events events;
|
||||
} ProtobufC_FDNotifyChange;
|
||||
|
||||
void protobuf_c_dispatch_dispatch (ProtobufCDispatch *dispatch,
|
||||
size_t n_notifies,
|
||||
ProtobufC_FDNotify *notifies);
|
||||
@ -93,8 +99,10 @@ void protobuf_c_dispatch_clear_changes (ProtobufCDispatch *);
|
||||
struct _ProtobufCDispatch
|
||||
{
|
||||
/* changes to the events you are interested in. */
|
||||
/* (this handles closed file-descriptors
|
||||
in a manner agreeable to epoll(2) and kqueue(2)) */
|
||||
size_t n_changes;
|
||||
ProtobufC_FDNotify *changes;
|
||||
ProtobufC_FDNotifyChange *changes;
|
||||
|
||||
/* the complete set of events you are interested in. */
|
||||
size_t n_notifies_desired;
|
||||
@ -112,7 +120,7 @@ struct _ProtobufCDispatch
|
||||
unsigned long last_dispatch_secs;
|
||||
unsigned last_dispatch_usecs;
|
||||
|
||||
/* private data follows */
|
||||
/* private data follows (see RealDispatch structure in .c file) */
|
||||
};
|
||||
|
||||
void protobuf_c_dispatch_destroy_default (void);
|
||||
|
@ -47,6 +47,17 @@ ProtobufCService *protobuf_c_rpc_client_new (ProtobufC_RPC_AddressType type,
|
||||
const ProtobufCServiceDescriptor *descriptor,
|
||||
ProtobufCDispatch *dispatch);
|
||||
|
||||
/* forcing the client to connect */
|
||||
typedef enum
|
||||
{
|
||||
PROTOBUF_C_RPC_CLIENT_CONNECT_SUCCESS,/* also returned if already connected */
|
||||
PROTOBUF_C_RPC_CLIENT_CONNECT_ERROR_NAME_LOOKUP,
|
||||
PROTOBUF_C_RPC_CLIENT_CONNECT_ERROR_CONNECT
|
||||
} ProtobufC_RPC_Client_ConnectStatus;
|
||||
|
||||
ProtobufC_RPC_Client_ConnectStatus
|
||||
protobuf_c_rpc_client_connect (ProtobufC_RPC_Client *client);
|
||||
|
||||
/* --- configuring the client */
|
||||
typedef struct _ProtobufC_RPC_Client ProtobufC_RPC_Client;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user