# SuperMsgQueue **Repository Path**: masterlovsky/super-msg-queue ## Basic Information - **Project Name**: SuperMsgQueue - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-08-14 - **Last Updated**: 2025-08-14 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # SuperMsgQ 一个使用 C++17 + CMake 构建的线程安全消息队列(PIMPL)。 特性: - 并发线程安全(互斥量 + 条件变量) - PIMPL 对外仅暴露接口 - 自定义消息字段 {id, title, content, timestamp, ttl} - 支持消息生命周期(默认 TTL,可单条覆盖) - 支持消息去重(基于 id) ## 目录结构 ``` . ├── CMakeLists.txt ├── include │ └── SuperMsgQueue.h ├── src │ └── SuperMsgQueue.cpp └── examples └── demo.cpp ``` ## 构建与运行 使用 CMake(Windows PowerShell): ```powershell # 配置与生成 cmake -S . -B build -DCMAKE_BUILD_TYPE=Release # 编译 cmake --build build --config Release # 运行示例 ./build/Release/smq_demo.exe # 运行CTest(可选) ctest --test-dir build -C Release -V ``` 注意:若使用多配置生成器(如 Visual Studio),可将可执行文件路径改为 `build/Release/smq_demo.exe`。 ## 使用要点 - enqueue:重复 id 会被拒绝(返回 false) - dequeue(timeout):阻塞等待直到有未过期消息或超时 - try_dequeue:非阻塞尝试 - purgeExpired:手动清理过期消息 - setDefaultTTL:设置默认 TTL(对 ttl=0 的消息生效) ## 许可 MIT