-
Notifications
You must be signed in to change notification settings - Fork 385
namespace ipc
mutouyun edited this page Dec 9, 2025
·
2 revisions
cpp-ipc的根命名空间,包含所有公开的类、函数和类型定义。
-
ipc::shm- 共享内存管理 -
ipc::sync- 进程间同步原语 -
ipc::mem- 内存分配和对象管理 -
ipc::circ- 循环数组数据结构(内部使用) -
ipc::tls- 线程本地存储(内部使用)
-
ipc::route- 单写多读IPC路由(1-to-N) -
ipc::channel- 多写多读IPC通道(N-to-N) -
ipc::buffer- 数据缓冲区 -
ipc::chan<Rp, Rc, Ts>- 自定义策略的IPC通道模板
-
ipc::spin_lock- 轻量级自旋锁 -
ipc::rw_lock- 读写锁
using byte_t = std::uint8_t;
using handle_t = void*;
using buff_t = buffer;
template <std::size_t N>
using uint_t = typename uint<N>::type;enum : std::uint32_t {
invalid_value = max_uint32, // 无效值/无限超时
default_timeout = 100, // 默认超时(毫秒)
};
enum : std::size_t {
data_length = 64, // 数据包大小
large_msg_limit = 64, // 大消息阈值
large_msg_cache = 32, // 大消息缓存数
};enum class relat { // 关系多重性
single, // 单个
multi // 多个
};
enum class trans { // 传输模式
unicast, // 单播
broadcast // 广播
};enum : unsigned {
sender, // 发送者模式
receiver // 接收者模式
};#include "libipc/ipc.h"
// 使用route进行1-to-N通讯
ipc::route producer{"my-route"};
ipc::route consumer{"my-route", ipc::receiver};
// 发送数据
producer.send("Hello!");
// 接收数据
auto buf = consumer.recv();