function lfds700_queue_dequeue

From liblfds.org
Jump to navigation Jump to search

Source Files

└───liblfds700
    ├───inc
    │   └───liblfds700
    │           lfds700_queue.h
    └───src
        └───lfds700_queue
                lfds700_queue_dequeue.c

Opaque Structures

struct lfds700_misc_prng_state;
struct lfds700_queue_element;
struct lfds700_queue_state;

Prototype

int lfds700_queue_dequeue( struct lfds700_queue_state *qs,
                           struct lfds700_queue_element **qe,
                           struct lfds700_misc_prng_state *ps );

Parameters

struct lfds700_queue_state *qs

A pointer to an initialized struct lfds700_queue_state.

struct lfds700_queue_element **qe

A pointer to a pointer to a struct lfds700_queue_state, which is set to point to the dequeued element.

struct lfds700_misc_prng_state *ps

A pointer to an initialized struct lfds700_misc_prng_state.

Return Value

Returns 1 on a successful dequeue. Returns 0 if dequeing failed. Dequeuing only fails if the queue is empty.

Notes

This function dequeues a queue element, with its key and value, from the queue. The key and value are read from the queue element by the macros LFDS700_QUEUE_GET_KEY_FROM_ELEMENT and LFDS700_QUEUE_GET_VALUE_FROM_ELEMENT respectively, and can only be correctly read when a queue element is outside of a queue; the macros can be issued at any time, of course, but if the element has not been dequeue by the thread calling the macro, then there is no guarantee the key and value read will be that which was written into the element. You were warned.

The third argument, the struct lfds700_misc_prng_state, is the state for a single-threaded, fast, high quality random number generator, required by the exponential backoff code. Each thread should allocate and initialize one of these structures, and then it can be used for all API calls which take this argument.

Example

Coming soon. No, really! (Written 29th Dec 2015).

See Also