Returns the length of the queue.
Actually this function returns the number of data items in
the queue minus the number of waiting threads, so a negative
value means waiting threads, and a positive value means available
entries in the queue. A return value of 0 could mean n entries
in the queue and n threads waiting. This can happen due to locking
of the queue or due to scheduling.
the length of the queue
Returns the length of the queue.
Actually this function returns the number of data items in
the queue minus the number of waiting threads, so a negative
value means waiting threads, and a positive value means available
entries in the queue. A return value of 0 could mean n entries
in the queue and n threads waiting. This can happen due to locking
of the queue or due to scheduling.
This function must be called while holding the queue's lock.
the length of the queue.
Acquires the queue's lock. If another thread is already
holding the lock, this call will block until the lock
becomes available.
Call g_async_queue_unlock() to drop the lock again.
While holding the lock, you can only call the
g_async_queue_*_unlocked() functions on queue. Otherwise,
deadlock may occur.
Pops data from the queue. If queue is empty, this function
blocks until data becomes available.
data from the queue
Pops data from the queue. If queue is empty, this function
blocks until data becomes available.
This function must be called while holding the queue's lock.
data from the queue.
Pushes the data into the queue.
The data parameter must not be null.
data to push onto the queue
Pushes the item into the queue. item must not be null.
In contrast to g_async_queue_push(), this function
pushes the new item ahead of the items already in the queue,
so that it will be the next one to be popped off the queue.
data to push into the queue
Pushes the item into the queue. item must not be null.
In contrast to g_async_queue_push_unlocked(), this function
pushes the new item ahead of the items already in the queue,
so that it will be the next one to be popped off the queue.
This function must be called while holding the queue's lock.
data to push into the queue
Inserts data into queue using func to determine the new
position.
This function requires that the queue is sorted before pushing on
new elements, see g_async_queue_sort().
This function will lock queue before it sorts the queue and unlock
it when it is finished.
For an example of func see g_async_queue_sort().
the data to push into the queue
the GLib.CompareDataFunc is used to sort queue
Inserts data into queue using func to determine the new
position.
The sort function func is passed two elements of the queue.
It should return 0 if they are equal, a negative value if the
first element should be higher in the queue or a positive value
if the first element should be lower in the queue than the second
element.
This function requires that the queue is sorted before pushing on
new elements, see g_async_queue_sort().
This function must be called while holding the queue's lock.
For an example of func see g_async_queue_sort().
the data to push into the queue
the GLib.CompareDataFunc is used to sort queue
Pushes the data into the queue.
The data parameter must not be null.
This function must be called while holding the queue's lock.
data to push onto the queue
Increases the reference count of the asynchronous queue by 1.
You do not need to hold the lock to call this function.
the queue that was passed in (since 2.6)
Increases the reference count of the asynchronous queue by 1.
Remove an item from the queue.
the data to remove from the queue
true if the item was removed
Remove an item from the queue.
This function must be called while holding the queue's lock.
the data to remove from the queue
true if the item was removed
Sorts queue using func.
The sort function func is passed two elements of the queue.
It should return 0 if they are equal, a negative value if the
first element should be higher in the queue or a positive value
if the first element should be lower in the queue than the second
element.
This function will lock queue before it sorts the queue and unlock
it when it is finished.
If you were sorting a list of priority numbers to make sure the lowest priority would be at the top of the queue, you could use:
gint32 id1;
gint32 id2;
id1 = GPOINTER_TO_INT (element1);
id2 = GPOINTER_TO_INT (element2);
return (id1 > id2 ? +1 : id1 == id2 ? 0 : -1);
the GLib.CompareDataFunc is used to sort queue
Sorts queue using func.
The sort function func is passed two elements of the queue.
It should return 0 if they are equal, a negative value if the
first element should be higher in the queue or a positive value
if the first element should be lower in the queue than the second
element.
This function must be called while holding the queue's lock.
the GLib.CompareDataFunc is used to sort queue
Pops data from the queue. If the queue is empty, blocks until
end_time or until data becomes available.
If no data is received before end_time, null is returned.
To easily calculate end_time, a combination of g_get_real_time()
and g_time_val_add() can be used.
a GLib.TimeVal, determining the final time
data from the queue or null, when no data is received before end_time.
Pops data from the queue. If the queue is empty, blocks until
end_time or until data becomes available.
If no data is received before end_time, null is returned.
To easily calculate end_time, a combination of g_get_real_time()
and g_time_val_add() can be used.
This function must be called while holding the queue's lock.
a GLib.TimeVal, determining the final time
data from the queue or null, when no data is received before end_time.
Pops data from the queue. If the queue is empty, blocks for
timeout microseconds, or until data becomes available.
If no data is received before the timeout, null is returned.
the number of microseconds to wait
data from the queue or null, when no data is received before the timeout.
Pops data from the queue. If the queue is empty, blocks for
timeout microseconds, or until data becomes available.
If no data is received before the timeout, null is returned.
This function must be called while holding the queue's lock.
the number of microseconds to wait
data from the queue or null, when no data is received before the timeout.
Tries to pop data from the queue. If no data is available,
null is returned.
data from the queue or null, when no data is available immediately.
Tries to pop data from the queue. If no data is available,
null is returned.
This function must be called while holding the queue's lock.
data from the queue or null, when no data is available immediately.
Releases the queue's lock.
Calling this function when you have not acquired
the with g_async_queue_lock() leads to undefined
behaviour.
Decreases the reference count of the asynchronous queue by 1.
If the reference count went to 0, the queue will be destroyed
and the memory allocated will be freed. So you are not allowed
to use the queue afterwards, as it might have disappeared.
You do not need to hold the lock to call this function.
Decreases the reference count of the asynchronous queue by 1
and releases the lock. This function must be called while holding
the queue's lock. If the reference count went to 0, the queue
will be destroyed and the memory allocated will be freed.
StaticnewCreates a new asynchronous queue.
Staticnew_Creates a new asynchronous queue and sets up a destroy notify function that is used to free any remaining queue items when the queue is destroyed after the final unref.
Optionalitem_free_func: DestroyNotifyfunction to free queue elements
An opaque data structure which represents an asynchronous queue.
It should only be accessed through the
g_async_queue_*functions.