CX Framework
Cross-platform C utility framework
Loading...
Searching...
No Matches
pool.h
Go to the documentation of this file.
1
21
22#pragma once
23// This header file is auto-generated!
24// Do not make changes to this file or they will be overwritten.
25// clang-format off
26#include <cx/obj.h>
27#include <cx/struct.h>
28#include <cx/net/net_shared.h>
29#include <cx/buffer/bufpool.h>
30
31CX_C_BEGIN
32
33typedef struct NetPool NetPool;
34typedef struct NetPool_WeakRef NetPool_WeakRef;
36saDeclarePtr(NetPool_WeakRef);
37#define _sti_NetPool _sti_object
38#define SType_NetPool NetPool*
39#define STStorageType_NetPool NetPool*
40#define STypeArg_NetPool(type, val) stgeneric(object, (ObjInst*)objInstCheckClass(NetPool, val))
41#define STypeArgPtr_NetPool(type, val) (stgeneric*)objInstCheckClassPtr(NetPool, val)
42#define STypeCheckedArg_NetPool(type, val) stType(type), stArg(type, val)
43#define STypeCheckedPtrArg_NetPool(type, val) stType(type), stArgPtr(type, val)
44
45
46
51typedef struct NetPool {
52 union {
53 ObjIface* _;
54 void* _is_NetPool;
55 void* _is_ObjInst;
56 };
57 ObjClassInfo* _clsinfo;
58 atomic(uintptr) _ref;
59 atomic(ptr) _weakref;
60
66 BufPool msgbuf;
68} NetPool;
69extern ObjClassInfo NetPool_clsinfo;
70#define NetPool(inst) objInstCheckClass(NetPool, inst)
71#define NetPoolNone ((NetPool*)NULL)
72
73typedef struct NetPool_WeakRef {
74 union {
75 ObjInst* _inst;
76 void* _is_NetPool_WeakRef;
77 void* _is_ObjInst_WeakRef;
78 };
79 atomic(uintptr) _ref;
80 RWLock _lock;
81} NetPool_WeakRef;
82#define NetPool_WeakRef(inst) objWeakRefCheckClass(NetPool, inst)
83
84_objfactory_guaranteed NetPool* NetPool_create(_In_ const NetQueueConfig* conf);
93#define netpoolCreate(conf) NetPool_create(conf)
94
95NetMessage* NetPool_allocHeader(_In_ NetPool* self);
110#define netpoolAllocHeader(self) NetPool_allocHeader(NetPool(self))
111
112_Check_return_ _Ret_maybenull_ NetMessage* NetPool_allocMsg(_In_ NetPool* self);
132#define netpoolAllocMsg(self) NetPool_allocMsg(NetPool(self))
133
134_At_(*msg, _Pre_notnull_ _Post_null_) void NetPool_freeMsg(_In_ NetPool* self, _Inout_ NetMessage** msg);
145#define netpoolFreeMsg(self, msg) NetPool_freeMsg(NetPool(self), msg)
146
147void NetPool_freeMsgQueue(_In_ NetPool* self, _Inout_ NetMsgQueue* mq);
157#define netpoolFreeMsgQueue(self, mq) NetPool_freeMsgQueue(NetPool(self), mq)
158
159
160CX_C_END
Thread-safe pool of fixed-size buffers.
#define saDeclarePtr(name)
Definition sarray.h:100
#define _objfactory_guaranteed
Definition objimpl.h:106
CX Struct System - Introspectable, serializable POD structures in C.
CX Object System - Object-oriented programming in C.
A received packet, as delivered to a handler.
Definition net_shared.h:361
Simple intrusive FIFO of NetMessage, linked through NetMessage::next.
Definition net_shared.h:416
Shared, capped pool of network message buffers and headers.
Definition pool.h:51
BufPool msgbuf
Pooled receive buffers, capped at queue creation.
Definition pool.h:66
PrQueue msghdr
Free NetMessage headers, so the steady-state packet path allocates nothing.
Definition pool.h:67