int server_queue_push(server_queue_t *queue, void *foo)
This function adds an entry to the back of the queue with the payload specified in foo. If you created the queue with the SERVER_QUEUE_ENTRY_SUPPLIED option, you are expected to supply a server_queue_entry_t * in place of the void * payload, with your payload of interest assigned to the foo member of the server_queue_entry_t.
It returns 1 on success 0 on failure.
When not using a SERVER_QUEUE_ENTRY_SUPPLIED queue, this call can block perhaps indefinitely, if the queue is maxed out and nobody is consuming anything from it, ever.
Without SERVER_QUEUE_ENTRY_SUPPLIED this function has to allocate an entry to place on the linked list, it does this using a ServerKit heap since the entries are of fixed size. Generally, this should work quite well and over time the heap will grow to a high water mark and expensive allocations will cease, the problem is when no threads pull from the queue but you continue to push. The heap will continue to grow, to unlimited size if SERVER_QUEUE_UNLIMITED is set, and eventually simply exhaust memory and fail if nothing ever consumes from the queue. So you must be careful especially in the consumer side, especially when using the unlimited option.
2007-12-06