Basics
Guides
API Reference
Basics
Guides
API Reference
[13:7] extends: object
An opaque data structure which represents an asynchronous queue. It should
only be accessed through the g_async_queue_* functions.
GAsyncQueue (Handle = null)
Creates a new
AsyncQueueby wrapping a native handle or another wrapper.
Handle is the native handle or another wrapper whose handle to adopt.toNativeHandle (Source)
Normalizes a constructor argument into a raw pointer carrier. Accepts a raw NativeHandle, a raw NativeBuffer returned from
fn.call(...), another generated wrapper exposinghandle(), or null. Returns null when the argument carries no pointer.
Source is the raw handle, raw buffer, wrapper, or null.A raw pointer carrier or null when no pointer is present.getLib ()
Returns the opened native library for this generated wrapper.
The opened native library.handle ()
Returns the wrapped NativeHandle.
The wrapped NativeHandle.isNull ()
Returns true when the wrapped handle is null.
A bool.describe ()
Returns a small string for debugging generated wrappers.
A string.length ()
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.length_unlocked ()
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..lock ()
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.
None.pop ()
Pops data from the @queue. If @queue is empty, this function blocks until data becomes available.
data from the queue.pop_unlocked ()
Pops data from the @queue. If @queue is empty, this function blocks until data becomes available. This function must be called while holding the
lock.data from the queue..push (data)
Pushes the @data into the @queue. The @data parameter must not be %NULL.
data is data to push onto the @queue.None.push_front (item)
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.
item is data to push into the @queue.None.push_front_unlocked (item)
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
lock.item is data to push into the @queue.None.push_sorted (data, user_data)
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
see g_async_queue_sort().data is the @data to push into the @queue.func is the #GCompareDataFunc is used to sort @queue.user_data is user data passed to @func..None.push_sorted_unlocked (data, user_data)
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
lock. For an example of @func see g_async_queue_sort().data is the data to push into the @queue.func is the #GCompareDataFunc is used to sort @queue.user_data is user data passed to @func..None.push_unlocked (data)
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 is data to push onto the @queue.None.ref ()
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).ref_unlocked ()
Increases the reference count of the asynchronous @queue by 1.
None.remove (item)
Remove an item from the queue.
item is the data to remove from the @queue.%TRUE if the item was removed.remove_unlocked (item)
Remove an item from the queue. This function must be called while holding the @queue's lock.
item is the data to remove from the @queue.%TRUE if the item was removed.sort (user_data)
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); ]|
func is the #GCompareDataFunc is used to sort @queue.user_data is user data passed to @func.None.sort_unlocked (user_data)
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.
func is the #GCompareDataFunc is used to sort @queue.user_data is user data passed to @func.None.timed_pop (object 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.
end_time is a #GTimeVal, determining the final time.data from the queue or %NULL, when no data is received beforetimed_pop_unlocked (object 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.
end_time is a #GTimeVal, determining the final time.data from the queue or %NULL, when no data is received beforetimeout_pop (int 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.
timeout is the number of microseconds to wait.data from the queue or %NULL, when no data is received before the timeout..timeout_pop_unlocked (int 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.
timeout is the number of microseconds to wait.data from the queue or %NULL, when no data is received before the timeout..try_pop ()
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..try_pop_unlocked ()
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..unlock ()
Releases the queue's lock. Calling this function when you have not acquired the with g_async_queue_lock() leads to undefined behaviour.
None.unref ()
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.
None.unref_and_unlock ()
Decreases the reference count of the asynchronous @queue by 1 and releases the lock. This function must be called while holding the
lock. If the reference count went to 0, the @queue will be destroyed and the memory allocated will be freed.None.
Aussom
Write once. Embed everywhere.
Copyright 2026 Austin Lehman. All rights reserved.