| Iris Manual | ||||
|---|---|---|---|---|
| Top | Description | ||||
#define IRIS_TYPE_WSQUEUE #define IRIS_WSQUEUE (q) IrisWSQueue; GType iris_wsqueue_get_type (void); IrisQueue* iris_wsqueue_new (IrisQueue *global, IrisRRobin *peers); gpointer iris_wsqueue_try_steal (IrisWSQueue *queue, guint timeout); void iris_wsqueue_local_push (IrisWSQueue *queue, gpointer data); gpointer iris_wsqueue_local_pop (IrisWSQueue *queue);
IrisWSQueue is a work-stealing version of IrisQueue. It requires access to a global queue for a fallback when out of items. If no item can be retreived from the global queue, it will try to steal from its peers using the IrisRRobin of peer queues, which should also be IrisQueue based.
IrisQueue* iris_wsqueue_new (IrisQueue *global, IrisRRobin *peers);
Creates a new instance of IrisWSQueue.
A dequeue first tries to retreive from the local queue. If nothing is available in the queue, we check the global queue. If nothing is found in the global queue, then we will try to steal an item from a neighbor in the IrisRRobin.
|
An IrisQueue of global work items |
|
An IrisRRobin of peer thread IrisQueue's |
Returns : |
The newly created IrisWSQueue instance. |
gpointer iris_wsqueue_try_steal (IrisWSQueue *queue, guint timeout);
Tries to steal an item from the IrisWSQueue within the timeout specified.
|
An IrisWSQueue |
|
timeout in millseconds |
Returns : |
A gpointer or NULL if no items were available.
|
void iris_wsqueue_local_push (IrisWSQueue *queue, gpointer data);
Pushes an item onto the queue. This should only be called from the thread that owns the IrisWSQueue as it is not safe to call from other threads. Research shows that only work items yielded from the owning thread should land directly into this queue.
|
An IrisWSQueue |
|
a pointer to data |
gpointer iris_wsqueue_local_pop (IrisWSQueue *queue);
Performs a local pop on the queue. This should only be called by the thread that owns the IrisWSQueue.
|
An IrisWSQueue |
Returns : |
A pointer or NULL if the queue is empty.
|