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

# q\_search(3)

search for an entry in a smolq queue

## NAME

q\_search - search for an entry in a smolq queue

## LIBRARY

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

## SYNOPSIS

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

**int  q\_search(q\_t** *\*q***, void \*(\****f***)(void \*), void \*restrict** *arg***);**

Compile and link with *-llibrecast*.

## DESCRIPTION

**q\_search**() searches the queue *q* to find an entry that matches both *f* and *arg*.

No locks, so readers may read while we're searching, and writers may write.  If something is read while we search, we will still return a positive match for that item, even though it is no longer in the queue.  If a writer writes we will not notice that write. If this is a problem, for a particular use-case, an external lock will be required.

## RETURN VALUE

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

## ERRORS

The function can fail with any of the errors for [**sem\_getvalue**(3)](/sem_getvalue/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), [**q\_wait**(3)](/q_wait/3.md), [**sem\_getvalue**(3)](/sem_getvalue/3.md).
