CX Framework
Cross-platform C utility framework
Loading...
Searching...
No Matches
bufpool.h
Go to the documentation of this file.
1#pragma once
2
3#include <cx/cx.h>
4#include <cx/buffer/buffer.h>
5#include <cx/thread/atomic.h>
6#include <cx/thread/prqueue.h>
7
10
52
53typedef struct BufPool {
54 PrQueue freelist;
55 size_t bufsz;
56 uint32 max;
57 atomic(uint32) count;
58} BufPool;
59
74void bufpoolInit(_Out_ BufPool* pool, size_t bufsz, uint32 initial, uint32 max);
75
85_Must_inspect_result_ _Ret_maybenull_ Buffer bufpoolGet(_Inout_ BufPool* pool);
86
95_At_(*buf, _Pre_maybenull_ _Post_null_) void bufpoolPut(_Inout_ BufPool* pool,
96 _Inout_ Buffer* buf);
97
104uint32 bufpoolInUse(_In_ BufPool* pool);
105
115void bufpoolCollect(_Inout_ BufPool* pool);
116
123void bufpoolDestroy(_Pre_valid_ _Post_invalid_ BufPool* pool);
124
Atomic operations.
Simple buffer management.
void bufpoolPut(BufPool *pool, Buffer *buf)
void bufpoolCollect(BufPool *pool)
Buffer bufpoolGet(BufPool *pool)
void bufpoolInit(BufPool *pool, size_t bufsz, uint32 initial, uint32 max)
void bufpoolDestroy(BufPool *pool)
uint32 bufpoolInUse(BufPool *pool)
Lock-free pointer FIFO queue.