### Struct

# GLib AsyncQueue

#### Description

    struct GAsyncQueue {
      /* No available fields */
    }

An opaque data structure which represents an asynchronous queue.

It should only be accessed through the `g_async_queue_*` functions.

#### Functions

###### g_async_queue_new

Creates a new asynchronous queue.

###### g_async_queue_new_full

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.

since: 2.16

#### Instance methods

###### g_async_queue_length

Returns the length of the queue.

###### g_async_queue_length_unlocked

Returns the length of the queue.

###### g_async_queue_lock

Acquires the `queue`‘s lock. If another thread is already holding the lock, this call will block until the lock becomes available.

###### g_async_queue_pop

Pops data from the `queue`. If `queue` is empty, this function blocks until data becomes available.

###### g_async_queue_pop_unlocked

Pops data from the `queue`. If `queue` is empty, this function blocks until data becomes available.

###### g_async_queue_push

Pushes the `data` into the `queue`.

###### g_async_queue_push_front

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.

since: 2.46

###### g_async_queue_push_front_unlocked

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.

since: 2.46

###### g_async_queue_push_sorted

Inserts `data` into `queue` using `func` to determine the new position.

since: 2.10

###### g_async_queue_push_sorted_unlocked

Inserts `data` into `queue` using `func` to determine the new position.

since: 2.10

###### g_async_queue_push_unlocked

Pushes the `data` into the `queue`.

###### g_async_queue_ref

Increases the reference count of the asynchronous `queue` by 1. You do not need to hold the lock to call this function.

###### g_async_queue_ref_unlocked

Increases the reference count of the asynchronous `queue` by 1.

deprecated: 2.8

###### g_async_queue_remove

Remove an item from the queue.

since: 2.46

###### g_async_queue_remove_unlocked

Remove an item from the queue.

since: 2.46

###### g_async_queue_sort

Sorts `queue` using `func`.

since: 2.10

###### g_async_queue_sort_unlocked

Sorts `queue` using `func`.

since: 2.10

###### g_async_queue_timed_pop

Pops data from the `queue`. If the queue is empty, blocks until `end_time` or until data becomes available.

deprecated: Unknown

###### g_async_queue_timed_pop_unlocked

Pops data from the `queue`. If the queue is empty, blocks until `end_time` or until data becomes available.

deprecated: Unknown

###### g_async_queue_timeout_pop

Pops data from the `queue`. If the queue is empty, blocks for `timeout` microseconds, or until data becomes available.

###### g_async_queue_timeout_pop_unlocked

Pops data from the `queue`. If the queue is empty, blocks for `timeout` microseconds, or until data becomes available.

###### g_async_queue_try_pop

Tries to pop data from the `queue`. If no data is available, `NULL` is returned.

###### g_async_queue_try_pop_unlocked

Tries to pop data from the `queue`. If no data is available, `NULL` is returned.

###### g_async_queue_unlock

Releases the queue’s lock.

###### g_async_queue_unref

Decreases the reference count of the asynchronous `queue` by 1.

###### g_async_queue_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 `queue`‘s lock. If the reference count went to 0, the `queue` will be destroyed and the memory allocated will be freed.

deprecated: 2.8