server_queue_new()

server_queue_t * server_queue_new(const char *label, int max, int options)

Creates a new queue, max is the maximum length of the queue, options is used to alter the behavior of the queue, currently two options are supported:

Returns the new queue on success or NULL on failure.

Supported options:

SERVER_QUEUE_UNLIMITED
Causes the max value to be ignored.
SERVER_QUEUE_ENTRY_SUPPLIED
Instructs the queue to NOT create its own internal heap for allocating queue entry space. Using this option requires that the caller pass server_queue_entry_t *'s in the void * payload spaces.

This option is intended for improved queue efficiency when you are working with payloads that will never exist on more than one queue at a time. In these situations you can simply nest the server_queue_entry_t structure within the payload data structure. Assign the payload pointer to the foo member of the server_queue_entry_t, then use the server_queue_entry_t * when interfacing with the queue.

The queue will give back the server_queue_entry_t on pull/cycle calls, and will make no attempt to free or otherwise manage the queue entry space. You access the payload by casting the void * to a server_queue_entry_t * and dereferencing the foo member.

The label is a name you should place some context in so when ServerKit reports statistics about its primitives you can see which statistics are from what parts of your program, there will likely be many heaps/queues in use at once.

2007-12-06