CX Framework
Cross-platform C utility framework
Loading...
Searching...
No Matches
closure_private.h
1#pragma once
2
3#include <cx/thread/atomic.h>
4#include <cx/thread/rwlock.h>
5#include "closure.h"
6
7typedef struct Closure {
8 // Type-erased: a closureFunc for a generic closure, or whatever signature it was created
9 // with for a typed one. Only ever called through a cast back to the type in `sig`.
10 void (*func)(void);
11 // NULL for a generic closure, otherwise the name of the typed signature it was created with.
12 // Checked on every call in debug builds, since the call-site cast cannot be.
13 const char* sig;
14 // Optional; runs once from closureDestroy() while the captured variables are still intact.
15 closureDestroyFunc destroy;
16 int nvars;
17 stvar cvars[];
18} Closure;
19
20typedef struct CChainNode CChainNode;
21typedef struct CChainNode {
22 CChainNode* prev;
23 closureFunc func;
24 intptr token;
25 atomic(uint32) refcount;
26 int nvars;
27 stvar cvars[];
28} CChainNode;
29
30intptr _closureCompare(_In_ closure cls1, _In_ closure cls2);
Atomic operations.
void(* closureDestroyFunc)(stvlist *cvars)
Definition closure.h:201
bool(* closureFunc)(stvlist *cvars, stvlist *args)
Definition closure.h:122
#define stvar(typen, val)
Definition stvar.h:162
Closures and callback chains aggregated header.
Reader-writer lock synchronization primitive.