CX Framework
Cross-platform C utility framework
Loading...
Searching...
No Matches
threadobj.h
1#pragma once
2// This header file is auto-generated!
3// Do not make changes to this file or they will be overwritten.
4// clang-format off
5#include <cx/obj.h>
6#include <cx/struct.h>
7#include <cx/stype/stvar.h>
9#include <cx/thread/atomic.h>
10#include <cx/thread/event.h>
11#include <cx/thread/threadbase.h>
12
13CX_C_BEGIN
14
15typedef struct Thread Thread;
16typedef struct Thread_WeakRef Thread_WeakRef;
17saDeclarePtr(Thread);
18saDeclarePtr(Thread_WeakRef);
19#define _sti_Thread _sti_object
20#define SType_Thread Thread*
21#define STStorageType_Thread Thread*
22#define STypeArg_Thread(type, val) stgeneric(object, (ObjInst*)objInstCheckClass(Thread, val))
23#define STypeArgPtr_Thread(type, val) (stgeneric*)objInstCheckClassPtr(Thread, val)
24#define STypeCheckedArg_Thread(type, val) stType(type), stArg(type, val)
25#define STypeCheckedPtrArg_Thread(type, val) stType(type), stArgPtr(type, val)
26
27typedef struct Thread {
28 union {
29 ObjIface* _;
30 void* _is_Thread;
31 void* _is_ObjInst;
32 };
33 ObjClassInfo* _clsinfo;
34 atomic(uintptr) _ref;
35 atomic(ptr) _weakref;
36
37 threadFunc entry;
38 string name;
39 int exitCode; // only valid once 'running' become false
40 stvlist args;
41 sa_stvar _argsa; // should use the stvlist instead where possible
42 atomic(bool) running;
43 atomic(bool) requestExit;
44 Event notify;
45} Thread;
46extern ObjClassInfo Thread_clsinfo;
47#define Thread(inst) objInstCheckClass(Thread, inst)
48#define ThreadNone ((Thread*)NULL)
49
50typedef struct Thread_WeakRef {
51 union {
52 ObjInst* _inst;
53 void* _is_Thread_WeakRef;
54 void* _is_ObjInst_WeakRef;
55 };
56 atomic(uintptr) _ref;
57 RWLock _lock;
58} Thread_WeakRef;
59#define Thread_WeakRef(inst) objWeakRefCheckClass(Thread, inst)
60
61_objfactory_guaranteed Thread* Thread_create(threadFunc func, _In_opt_ strref name, int n, stvar args[], bool ui);
62// Thread* _throbjCreate(threadFunc func, strref name, int n, stvar args[], bool ui);
63#define _throbjCreate(func, name, n, args, ui) Thread_create(func, name, n, args, ui)
64
65
66CX_C_END
Atomic operations.
Event synchronization primitive.
#define saDeclarePtr(name)
Definition sarray.h:100
#define _objfactory_guaranteed
Definition objimpl.h:106
#define stvar(typen, val)
Definition stvar.h:162
CX Struct System - Introspectable, serializable POD structures in C.
CX Object System - Object-oriented programming in C.
Dynamic arrays with type-safe generic programming.
Definition event.h:53
Variant type containers and type-safe variadic argument support.