q_search(3)

q_search3

Search for an entry in a smolq queue

Usage

#include <librecast/q.h>

int q_search(q_t *q, void *(*f)(void *), void *restrict arg);

Compile and link with -llibrecast.

Library

Librecast library (liblibrecast, -llibrecast)

Overview

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).

From liblibrecast-dev 0.9.1-1 in Debian 13 (Trixie). Parsed by carta from the page's man source.