---
name: "q_wait"
section: "3"
platform: "linux"
package: "liblibrecast-dev"
version: "0.9.1-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/q_wait"
---

# q\_wait(3)

return the next job from the queue, when available

## NAME

q\_wait - return the next job from the queue, when available

## LIBRARY

Librecast library (*liblibrecast*, *-llibrecast*)

## SYNOPSIS

```
#include <librecast/q.h>
```

**int q\_wait(q\_t** *\*q***, q\_job\_t** *\*job***);** **int q\_trywait(q\_t** *\*q***, q\_job\_t** *\*job***);**

Compile and link with *-llibrecast*.

## DESCRIPTION

**q\_wait**() atomically fetches the next *job* in *q* and sets the *job* pointer to it. The call blocks until a job is available.

**q\_trywait**() is the same as **q\_wait**() except that if the queue read lock cannot be immediately obtained, then the call returns an error (*errno* set to **EAGAIN**) instead of blocking.

## RETURN VALUE

The **q\_push**() function returns zero on success. On error, -1 is returned and *errno* is set to indicate the error.

## ERRORS

The function can also fail with the errors for [**sem\_post**(3)](/sem_post/3.md) or [**sem\_wait**(3)](/sem_wait/3.md).

## SEE ALSO

[**q\_job\_seek**(3)](/q_job_seek/3.md), [**q\_pool\_create**(3)](/q_pool_create/3.md), [**q\_pool\_destroy**(3)](/q_pool_destroy/3.md), [**q\_init**(3)](/q_init/3.md), [**q\_free**(3)](/q_free/3.md), [**q\_push**(3)](/q_push/3.md), [**sem\_post**(3)](/sem_post/3.md), [**sem\_wait**(3)](/sem_wait/3.md)
