server_queue_pull()

int server_queue_pull(server_queue_t *queue, int block, void **foo)

This function removes an entry from the front of the queue, stores the payload at the memory pointed at by foo. If you specify 1 for block, and the queue is empty, the function will wait until something is available, perhaps forever if nothing ever gets pushed onto the queue.

Returns 0 on error or empty queue w/0 specified for block, and 1 on success (success means the memory foo points at now has the payload, should be safe to use it).

When not using a SERVER_QUEUE_ENTRY_SUPPLIED queue, after storing the payload at the memory pointed at by foo, the entry is freed for you using server_heap_unit_unref(), so that it may be reused by a server_queue_push() call ASAP.

When using SERVER_QUEUE_ENTRY_SUPPLIED, instead of storing the payload at the void **foo space provided the server_queue_entry_t * you supplied to server_queue_push() is stored, and ServerKit does no freeing on your behalf. You must cast the void * pointer to server_queue_entry_t * and access the payload in the foo member of the server_queue_entry_t.



2007-12-06