OpenSync  0.22
Data Structures | Enumerations
OpenSync Message Queues Internals
OpenSync Engine Private API

A Queue used for asynchronous communication between thread. More...

Data Structures

struct  OSyncQueue
 Represents a Queue which can be used to receive messages. More...

Enumerations

enum  OSyncQueueEvent { OSYNC_QUEUE_EVENT_NONE, OSYNC_QUEUE_EVENT_READ, OSYNC_QUEUE_EVENT_ERROR, OSYNC_QUEUE_EVENT_HUP }
enum  OSyncQueueType { OSYNC_QUEUE_SENDER, OSYNC_QUEUE_RECEIVER }
int _osync_queue_write_data (OSyncQueue *queue, const void *vptr, size_t n, OSyncError **error)
osync_bool _osync_queue_write_long_long_int (OSyncQueue *queue, const long long int message, OSyncError **error)
osync_bool _osync_queue_write_int (OSyncQueue *queue, const int message, OSyncError **error)
OSyncQueueosync_queue_new (const char *name, OSyncError **error)
 Creates a new asynchronous queue.
osync_bool osync_queue_new_pipes (OSyncQueue **read_queue, OSyncQueue **write_queue, OSyncError **error)
void osync_queue_free (OSyncQueue *queue)
osync_bool osync_queue_exists (OSyncQueue *queue)
osync_bool osync_queue_create (OSyncQueue *queue, OSyncError **error)
osync_bool osync_queue_remove (OSyncQueue *queue, OSyncError **error)
osync_bool osync_queue_connect (OSyncQueue *queue, OSyncQueueType type, OSyncError **error)
osync_bool osync_queue_try_connect (OSyncQueue *queue, OSyncQueueType type, OSyncError **error)
osync_bool osync_queue_disconnect (OSyncQueue *queue, OSyncError **error)
osync_bool osync_queue_is_connected (OSyncQueue *queue)
void osync_queue_set_message_handler (OSyncQueue *queue, OSyncMessageHandler handler, gpointer user_data)
 Sets the message handler for a queue.
void osync_queue_setup_with_gmainloop (OSyncQueue *queue, GMainContext *context)
 Sets the queue to use the gmainloop with the given context.
osync_bool osync_queue_dispatch (OSyncQueue *queue, OSyncError **error)
OSyncQueueEvent osync_queue_poll (OSyncQueue *queue)
OSyncMessageosync_queue_get_message (OSyncQueue *queue)
void gen_id (long long int *part1, int *part2)
osync_bool osync_queue_send_message (OSyncQueue *queue, OSyncQueue *replyqueue, OSyncMessage *message, OSyncError **error)
osync_bool osync_queue_send_message_with_timeout (OSyncQueue *queue, OSyncQueue *replyqueue, OSyncMessage *message, int timeout, OSyncError **error)
osync_bool osync_queue_is_alive (OSyncQueue *queue)

Detailed Description

A Queue used for asynchronous communication between thread.


Function Documentation

OSyncQueue* osync_queue_new ( const char *  name,
OSyncError **  error 
)

Creates a new asynchronous queue.

This function return the pointer to a newly created OSyncQueue

Definition at line 461 of file opensync_queue.c.

void osync_queue_set_message_handler ( OSyncQueue queue,
OSyncMessageHandler  handler,
gpointer  user_data 
)

Sets the message handler for a queue.

Sets the function that will receive all messages, except the methodcall replies

Parameters:
queueThe queue to set the handler on
handlerThe message handler function
user_dataThe userdata that the message handler should receive

Definition at line 746 of file opensync_queue.c.

Referenced by osengine_init().

void osync_queue_setup_with_gmainloop ( OSyncQueue queue,
GMainContext *  context 
)

Sets the queue to use the gmainloop with the given context.

This function will attach the OSyncQueue as a source to the given context. The queue will then be check for new messages and the messages will be handled.

Parameters:
queueThe queue to set up
contextThe context to use. NULL for default loop

Definition at line 766 of file opensync_queue.c.

Referenced by osengine_init().

OSyncMessage* osync_queue_get_message ( OSyncQueue queue)

note that this function is blocking

Definition at line 827 of file opensync_queue.c.