CX Framework
Cross-platform C utility framework
Loading...
Searching...
No Matches
Closure Callbacks

Functions

bool ccbSignalEvent (stvlist *cvars, stvlist *args)
 
bool ccbSignalSharedEvent (stvlist *cvars, stvlist *args)
 
bool ccbAdvanceTask (stvlist *cvars, stvlist *args)
 

Detailed Description

Provides ready-to-use closure callback functions for common operations like event signaling and task management. These functions are designed to work with the closure and closure chain systems (see Closures and Closure Chains).

These callbacks are particularly useful for deferred execution, event handling, and coordination between asynchronous operations. Each callback expects specific captured variables (cvars) as documented.

Example usage with closure chains:

cchain myChain = NULL;
// Attach callback that will signal and release the shared event when chain is called
// Acquire a reference to hand off to the callback
// Later, when chain is called, the event will be signaled and released
cchainCall(&myChain);
// Wait for event on another thread
cchainDestroy(&myChain);
#define cchainCall(chain,...)
Definition cchain.h:127
#define cchainAttach(chain, func,...)
Definition cchain.h:81
void cchainDestroy(cchain *chain)
#define stvar(typen, val)
Definition stvar.h:153
SharedEvent * sheventCreate(uint32 flags)
void eventWait(Event *e)
Definition event.h:160
void sheventRelease(SharedEvent **pev)
SharedEvent * sheventAcquire(SharedEvent *ev)
#define timeForever
Maximum representable time value (approximately year 294,276 CE)
Definition time.h:13
bool ccbSignalSharedEvent(stvlist *cvars, stvlist *args)
Event ev
Underlying event.
Definition event.h:98

Function Documentation

◆ ccbAdvanceTask()

bool ccbAdvanceTask ( stvlist cvars,
stvlist args 
)

Advance a complex task

Closure callback that advances a ComplexTask given a weak reference. Acquires the task from the weak reference, advances it, then releases the task. If the weak reference is invalid (task destroyed), does nothing. Ignores call-time arguments.

This is useful for scheduling task advancement in response to events or callbacks.

Captured variables:

Parameters
cvarsCaptured variables containing weak task reference
argsCall-time arguments (ignored)
Returns
true on success, false if weak reference is NULL or task is destroyed

◆ ccbSignalEvent()

bool ccbSignalEvent ( stvlist cvars,
stvlist args 
)

Signal an event

Closure callback that signals an Event. Expects the event pointer as the first captured variable (cvar). Ignores call-time arguments.

Captured variables:

  • cvar[0]: Event* - Pointer to event to signal
Parameters
cvarsCaptured variables containing Event pointer
argsCall-time arguments (ignored)
Returns
true on success, false if event pointer is NULL

◆ ccbSignalSharedEvent()

bool ccbSignalSharedEvent ( stvlist cvars,
stvlist args 
)

Signal and release a shared event

Closure callback that signals a SharedEvent and then releases the reference. Expects the shared event pointer as the first captured variable. Ignores call-time arguments.

This is useful for one-time event notifications where the shared event reference should be released after signaling.

Captured variables:

  • cvar[0]: SharedEvent* - Pointer to shared event to signal and release
Parameters
cvarsCaptured variables containing SharedEvent pointer
argsCall-time arguments (ignored)
Returns
true on success, false if shared event pointer is NULL