C Collections

cthreadpool · Section 3

cthrpool_try_submit

cthrpool_try_submit - submit a task without blocking

C Collections (libccollections, -lccollections)

#include <ccollections/cthreadpool.h>
 
ccol_retval cthrpool_try_submit(cthrpool pool,
                                  void (*fn)(void *),
                                  void *arg,
                                  void (*on_complete)(void *arg, bool ran));

The same as cthrpool_submit, except that with a bounded queue it never
blocks: When the queue is at capacity it returns ccol_container_full at
once. With an unbounded queue it behaves exactly like cthrpool_submit.

pool         Thread pool handle
fn           Task function (must not be NULL)
arg          The library gives it to fn and on_complete (may be NULL)
on_complete  Called once for the task: on_complete(arg, true) after
             fn returns, or on_complete(arg, false) when the pool
             discards the task unrun (may be NULL)

ccol_success           - task enqueued.
ccol_invalid_args      - pool is CTHRPOOL_NULL or a stale/already-destroyed handle, or fn is NULL.
ccol_not_enough_memory - task struct allocation failed.
ccol_not_permitted     - pool is shutting down.
ccol_container_full    - bounded queue is at capacity (not returned for
                         unbounded queues).

cthrpool_submit(3), cthrpool_timed_submit(3)