OpenSync 0.22
opensync/opensync_queue_internals.h
00001 #ifndef _OPENSYNC_QUEUE_INTERNALS_H
00002 #define _OPENSYNC_QUEUE_INTERNALS_H
00003 
00012 
00013 typedef enum {
00014         OSYNC_QUEUE_EVENT_NONE,
00015         OSYNC_QUEUE_EVENT_READ,
00016         OSYNC_QUEUE_EVENT_ERROR,
00017         OSYNC_QUEUE_EVENT_HUP
00018 } OSyncQueueEvent;
00019 
00020 typedef enum {
00021         OSYNC_QUEUE_SENDER,
00022         OSYNC_QUEUE_RECEIVER
00023 } OSyncQueueType;
00024 
00027 struct OSyncQueue {
00028         OSyncQueueType type;
00030         int fd;
00032         char *name;
00034         OSyncMessageHandler message_handler;
00036         gpointer user_data;
00038         GSourceFuncs *incoming_functions;
00039         GSource *incoming_source;
00041         GMainContext *context;
00042         GMainContext *incomingContext;
00043         
00044         OSyncThread *thread;
00045         
00046         GAsyncQueue *incoming;
00047         GAsyncQueue *outgoing;
00048         
00049         GList *pendingReplies;
00050         GMutex *pendingLock;
00051         
00052         GSourceFuncs *write_functions;
00053         GSource *write_source;
00054         
00055         GSourceFuncs *read_functions;
00056         GSource *read_source;
00057         
00058         osync_bool connected;
00059 };
00060 
00063 int _osync_queue_write_data(OSyncQueue *queue, const void *vptr, size_t n, OSyncError **error);
00064 osync_bool _osync_queue_write_long_long_int(OSyncQueue *queue, const long long int message, OSyncError **error);
00065 osync_bool _osync_queue_write_int(OSyncQueue *queue, const int message, OSyncError **error);
00066 
00067 OSyncQueue *osync_queue_new(const char *name, OSyncError **error);
00068 osync_bool osync_queue_new_pipes(OSyncQueue **read_queue, OSyncQueue **write_queue, OSyncError **error);
00069 osync_bool osync_queue_create(OSyncQueue *queue, OSyncError **error);
00070 
00071 void osync_queue_free(OSyncQueue *queue);
00072 osync_bool osync_queue_remove(OSyncQueue *queue, OSyncError **error);
00073 osync_bool osync_queue_exists(OSyncQueue *queue);
00074 
00075 osync_bool osync_queue_connect(OSyncQueue *queue, OSyncQueueType type, OSyncError **error);
00076 osync_bool osync_queue_try_connect(OSyncQueue *queue, OSyncQueueType type, OSyncError **error);
00077 osync_bool osync_queue_disconnect(OSyncQueue *queue, OSyncError **error);
00078 osync_bool osync_queue_is_connected(OSyncQueue *queue);
00079 
00080 void osync_queue_set_message_handler(OSyncQueue *queue, OSyncMessageHandler handler, gpointer user_data);
00081 osync_bool osync_queue_send_message(OSyncQueue *queue, OSyncQueue *replyqueue, OSyncMessage *message, OSyncError **error);
00082 osync_bool osync_queue_send_message_with_timeout(OSyncQueue *queue, OSyncQueue *replyqueue, OSyncMessage *message, int timeout, OSyncError **error);
00083 
00084 void osync_queue_setup_with_gmainloop(OSyncQueue *queue, GMainContext *context);
00085 osync_bool osync_queue_dispatch(OSyncQueue *queue, OSyncError **error);
00086 
00087 OSyncQueueEvent osync_queue_poll(OSyncQueue *queue);
00088 
00089 OSyncMessage *osync_queue_get_message(OSyncQueue *queue);
00090 
00091 osync_bool osync_queue_is_alive(OSyncQueue *queue);
00092 
00093 #endif