tevent_queue(3)

πŸ“¦
version 0.17.1 Β· 3 versions
, in centos-stream 10, fedora 43, opensuse-leap 16.0

tevent_queue πŸ’–

okay bestie, welcome to tevent_queue(3) from the Library Functions Manual β€” yes it's a big one, but we're gonna get through it together, no cap. ✨


🌸 NAME 🌸

tevent_queue β€” the tevent queue functions, and honestly? iconic.

  • A tevent_queue is used to queue up async requests that must be serialized. πŸ’…

✨ SYNOPSIS ✨

πŸŽ€ Topics

The tevent operation functions

The following structure and registration functions are exclusively needed for people writing and plugging a different event engine. (iykyk β€” if that's you, hi, you're the main character here πŸ‘‘)

πŸ¦‹ Typedefs

  • typedef void(* tevent_queue_trigger_fn_t) (struct tevent_req *req, void *private_data) β€” a callback trigger function run by the queue.

🌈 Functions

  • void tevent_queue_entry_set_tag (struct tevent_queue_entry *qe, uint64_t tag) β€” associate a custom tag with the queue entry.
  • uint64_t tevent_queue_entry_get_tag (const struct tevent_queue_entry *qe) β€” get that custom queue entry tag back out.
  • void tevent_set_trace_queue_callback (struct tevent_context *ev, tevent_trace_queue_callback_t cb, void *private_data) β€” register a callback to be called at certain trace points of queue.
  • void tevent_get_trace_queue_callback (struct tevent_context *ev, tevent_trace_queue_callback_t *cb, void *p_private_data) β€” retrieve the current trace callback of queue.
  • struct tevent_queue * tevent_queue_create (TALLOC_CTX *mem_ctx, const char *name) β€” create and start a tevent queue.
  • bool tevent_queue_add (struct tevent_queue *queue, struct tevent_context *ev, struct tevent_req *req, tevent_queue_trigger_fn_t trigger, void *private_data) β€” add a tevent request to the queue.
  • struct tevent_queue_entry * tevent_queue_add_entry (struct tevent_queue *queue, struct tevent_context *ev, struct tevent_req *req, tevent_queue_trigger_fn_t trigger, void *private_data) β€” add a tevent request to the queue (this one hands you back the entry, slay).
  • struct tevent_queue_entry * tevent_queue_add_optimize_empty (struct tevent_queue *queue, struct tevent_context *ev, struct tevent_req *req, tevent_queue_trigger_fn_t trigger, void *private_data) β€” add a tevent request to the queue using a possible optimization.
  • void tevent_queue_entry_untrigger (struct tevent_queue_entry *entry) β€” untrigger an already triggered queue entry.
  • void tevent_queue_start (struct tevent_queue *queue) β€” start a tevent queue.
  • void tevent_queue_stop (struct tevent_queue *queue) β€” stop a tevent queue.
  • size_t tevent_queue_length (struct tevent_queue *queue) β€” get the length of the queue.
  • bool tevent_queue_running (struct tevent_queue *queue) β€” is the tevent queue running.
  • struct tevent_req * tevent_queue_wait_send (TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct tevent_queue *queue) β€” create a tevent subrequest that waits in a tevent_queue.
  • bool tevent_queue_wait_recv (struct tevent_req *req) β€” check if we no longer need to wait in the queue.
  • struct tevent_thread_proxy * tevent_thread_proxy_create (struct tevent_context *dest_ev_ctx) β€” create a tevent_thread_proxy for message passing between threads.
  • void tevent_thread_proxy_schedule (struct tevent_thread_proxy *tp, struct tevent_immediate **pp_im, tevent_immediate_handler_t handler, void *pp_private_data) β€” schedule an immediate event on an event context from another thread.

πŸ’œ Detailed Description πŸ’œ

A tevent_queue is used to queue up async requests that must be serialized. Like, one at a time, in order, no cutting the line. πŸšΆβ™€οΈπŸšΆβ™€οΈπŸšΆβ™€οΈ

For example, writing buffers into a socket must be serialized. Fr fr. Writing a large lump of data into a socket can require multiple write(2) or send(2) system calls. And if more than one async request is outstanding to write large buffers into a socket, every request must individually be completed before the next one begins β€” even if multiple syscalls are required. No skipping ahead, no vibes-based interleaving. 😀

Take a look at The tevent_queue tutorial for more details. 🫢


⭐ Typedef Documentation ⭐

typedef void(* tevent_queue_trigger_fn_t) (struct tevent_req *req, void *private_data)

A callback trigger function run by the queue. πŸ’«

Parameters

  • req β€” The tevent request the trigger function is executed on.
  • private_data β€” The private data pointer specified by tevent_queue_add().

See also

  • tevent_queue_add()
  • tevent_queue_add_entry()
  • tevent_queue_add_optimize_empty()

✨ Function Documentation ✨


πŸ¦‹ tevent_get_trace_queue_callback()

void tevent_get_trace_queue_callback (struct tevent_context * ev,
    tevent_trace_queue_callback_t * cb, void * p_private_data)

okay so bestie, this one retrieves the current trace callback of queue. Like, it hands you back the callback that's already vibing in there. πŸ’–

Parameters

  • ev β€” Event context
  • cb β€” Registered trace callback
  • p_private_data β€” Registered data to be passed to callback
πŸ“Œ Note: This can be used to allow one component that wants to register a callback to respect the callback that another component has already registered. So like… don't be the friend who steamrolls the group chat, okay? Respect the existing callback. 🫢

🌸 tevent_queue_add()

bool tevent_queue_add (struct tevent_queue * queue, struct tevent_context * ev,
    struct tevent_req * req, tevent_queue_trigger_fn_t trigger,
    void * private_data)

Add a tevent request to the queue. Straight up. The request joins the line and waits its turn like everyone else. πŸ‘‘

Parameters

  • queue β€” The queue to add the request.
  • ev β€” The event handle to use for the request.
  • req β€” The tevent request to add to the queue.
  • trigger β€” The function triggered by the queue when the request is called. Since tevent 0.9.14 it's possible to pass NULL, in order to just add a "blocker" to the queue.
  • private_data β€” The private data passed to the trigger function.

Returns

True if the request has been successfully added, false otherwise.


πŸŽ€ tevent_queue_add_entry()

struct tevent_queue_entry * tevent_queue_add_entry (struct tevent_queue * queue,
    struct tevent_context * ev, struct tevent_req * req,
    tevent_queue_trigger_fn_t trigger, void * private_data)

Add a tevent request to the queue β€” but this time it hands you back the receipt. 🧾 The request can be removed from the queue by calling talloc_free() (or a similar function) on the returned queue entry. This is the only difference to tevent_queue_add().

Parameters

  • queue β€” The queue to add the request.
  • ev β€” The event handle to use for the request.
  • req β€” The tevent request to add to the queue.
  • trigger β€” The function triggered by the queue when the request is called. Since tevent 0.9.14 it's possible to pass NULL, in order to just add a "blocker" to the queue.
  • private_data β€” The private data passed to the trigger function.

Returns

a pointer to the tevent_queue_entry if the request has been successfully added, NULL otherwise.

See also

  • tevent_queue_add()
  • tevent_queue_add_optimize_empty()

πŸ’… tevent_queue_add_optimize_empty()

struct tevent_queue_entry * tevent_queue_add_optimize_empty (struct tevent_queue * queue,
    struct tevent_context * ev, struct tevent_req * req,
    tevent_queue_trigger_fn_t trigger, void * private_data)

Add a tevent request to the queue using a possible optimization. ✨ This tries to optimize for the empty queue case and may calls the trigger function directly. This is the only difference compared to tevent_queue_add_entry().

The caller needs to be prepared that the trigger function has already called tevent_req_notify_callback(), tevent_req_error(), tevent_req_done() or a similar function. 😭 Like, no take-backs, it already happened, bestie.

The trigger function has no chance to see the returned queue_entry in the optimized case. πŸ™ˆ

The request can be removed from the queue by calling talloc_free() (or a similar function) on the returned queue entry.

Parameters

  • queue β€” The queue to add the request.
  • ev β€” The event handle to use for the request.
  • req β€” The tevent request to add to the queue.
  • trigger β€” The function triggered by the queue when the request is called. Since tevent 0.9.14 it's possible to pass NULL, in order to just add a "blocker" to the queue.
  • private_data β€” The private data passed to the trigger function.

Returns

a pointer to the tevent_queue_entry if the request has been successfully added, NULL otherwise.

See also

  • tevent_queue_add()
  • tevent_queue_add_entry()

🌈 tevent_queue_create()

struct tevent_queue * tevent_queue_create (TALLOC_CTX * mem_ctx, const char * name)

Create and start a tevent queue. Boom, a whole new queue, born ready. πŸ‘‘

Parameters

  • mem_ctx β€” The talloc memory context to allocate the queue.
  • name β€” The name to use to identify the queue.

Returns

An allocated tevent queue on success, NULL on error.

See also

  • tevent_queue_start()
  • tevent_queue_stop()

πŸ“ tevent_queue_entry_set_tag()

void tevent_queue_entry_set_tag (struct tevent_queue_entry * qe, uint64_t tag)

Associate a custom tag with the queue entry. 🏷️ This tag can be then retrieved with tevent_queue_entry_get_tag(). It's giving "personalized name tag at the party" energy.

Parameters

  • qe β€” The queue entry.
  • tag β€” Custom tag.

πŸ’€ tevent_queue_entry_untrigger()

void tevent_queue_entry_untrigger (struct tevent_queue_entry * entry)

Untrigger an already triggered queue entry. If a trigger function detects that it needs to remain in the queue, it needs to call tevent_queue_stop() followed by tevent_queue_entry_untrigger(). Order matters, bestie, do not freestyle this. 🚨

⚠️ Note: In order to call tevent_queue_entry_untrigger() the queue must be already stopped and the given queue_entry must be the first one in the queue! Otherwise it calls abort(). That's not a vibe, that's a crash. πŸ’€
🚫 You can't use this together with tevent_queue_add_optimize_empty() because the trigger function doesn't have access to the queue entry in the case of an empty queue.

Parameters

  • queue_entry β€” The queue entry to rearm.

See also

  • tevent_queue_add_entry()
  • tevent_queue_stop()

🧚 tevent_queue_length()

size_t tevent_queue_length (struct tevent_queue * queue)

Get the length of the queue. How many besties are waiting in line. πŸ’–

Parameters

  • queue β€” The queue to get the length from.

Returns

The number of elements.


⭐ tevent_queue_running()

bool tevent_queue_running (struct tevent_queue * queue)

Is the tevent queue running. The queue is started by default. πŸƒβ€β™€οΈ

Parameters

  • queue β€” The queue.

Returns

Whether the queue is running or not.


πŸ‘‘ tevent_queue_start()

void tevent_queue_start (struct tevent_queue * queue)

Start a tevent queue. The queue is started by default β€” so lowkey it was already running, but hey, you do you. ✨

Parameters

  • queue β€” The queue to start.

πŸ›‘ tevent_queue_stop()

void tevent_queue_stop (struct tevent_queue * queue)

Stop a tevent queue. The queue is started by default. Time to hit pause. ⏸️

Parameters

  • queue β€” The queue to stop.

πŸ¦‹ tevent_queue_wait_recv()

bool tevent_queue_wait_recv (struct tevent_req * req)

Check if we no longer need to wait in the queue. πŸ• This function needs to be called in the callback function set after calling tevent_queue_wait_send(). That's the rules, iykyk.

Parameters

  • req β€” The tevent request to check.

Returns

True on success, false otherwise.

See also

  • tevent_queue_wait_send()

🌸 tevent_queue_wait_send()

struct tevent_req * tevent_queue_wait_send (TALLOC_CTX * mem_ctx,
    struct tevent_context * ev, struct tevent_queue * queue)

Create a tevent subrequest that waits in a tevent_queue. The idea is that always the same syntax for tevent requests. Consistent queen behavior. πŸ’…

Parameters

  • mem_ctx β€” The talloc memory context to use.
  • ev β€” The event handle to setup the request.
  • queue β€” The queue to wait in.

Returns

The new subrequest, NULL on error.

See also

  • tevent_queue_wait_recv()

πŸ”₯ tevent_set_trace_queue_callback()

void tevent_set_trace_queue_callback (struct tevent_context * ev,
    tevent_trace_queue_callback_t cb, void * private_data)

Register a callback to be called at certain trace points of queue. πŸ“‘

Parameters

  • ev β€” Event context
  • cb β€” Trace callback
  • private_data β€” Data to be passed to callback
πŸ“Œ Note: The callback will be called at trace points defined by tevent_event_trace_point. Call with NULL to reset.

🧡 tevent_thread_proxy_create()

struct tevent_thread_proxy * tevent_thread_proxy_create (struct tevent_context * dest_ev_ctx)

Create a tevent_thread_proxy for message passing between threads. 🧡✨ The tevent_context must have been allocated on the NULL talloc context, and talloc_disable_null_tracking() must have been called. No cap, that's a hard requirement.

Parameters

  • dest_ev_ctx β€” The tevent_context to receive events.

Returns

An allocated tevent_thread_proxy, NULL on error. If tevent was compiled without PTHREAD support NULL is always returned and errno set to ENOSYS. 😭

See also

  • tevent_thread_proxy_schedule()

🌈 tevent_thread_proxy_schedule()

void tevent_thread_proxy_schedule (struct tevent_thread_proxy * tp,
    struct tevent_immediate ** pp_im, tevent_immediate_handler_t handler,
    void * pp_private_data)

Schedule an immediate event on an event context from another thread. 🧡πŸ”₯ Causes dest_ev_ctx, being run by another thread, to receive an immediate event calling the handler with the *pp_private parameter.

*pp_im must be a pointer to an immediate event talloced on a context owned by the calling thread, or the NULL context. Ownership will be transferred to the tevent_thread_proxy and *pp_im will be returned as NULL.

*pp_private_data must be a talloced area of memory with no destructors. Ownership of this memory will be transferred to the tevent library and *pp_private_data will be set to NULL on successful completion of the call. Set pp_private to NULL if no parameter transfer needed (a pure callback). This is an asynchronous request, caller does not wait for callback to be completed before returning. ⚑

Parameters

  • tp β€” The tevent_thread_proxy to use.
  • pp_im β€” Pointer to immediate event pointer.
  • handler β€” The function that will be called.
  • pp_private_data β€” The talloced memory to transfer.

See also

  • tevent_thread_proxy_create()

🫢 Author

Generated automatically by Doxygen for tevent from the source code.


and that's a wrap on tevent_queue(3), bestie πŸ’– this whole page was auto-generated by Doxygen for tevent, and it's riding with Version 0.9.8 β€” go forth and queue responsibly, mwah πŸŽ€βœ¨