Skip to content

feat(concurrentqueue): add compat.concurrentqueue 1.0.5 - #278

Merged
Sunrisepeak merged 1 commit into
mcpplibs:mainfrom
gzj-creator:feat/add-concurrentqueue
Aug 29, 2026
Merged

feat(concurrentqueue): add compat.concurrentqueue 1.0.5#278
Sunrisepeak merged 1 commit into
mcpplibs:mainfrom
gzj-creator:feat/add-concurrentqueue

Conversation

@gzj-creator

Copy link
Copy Markdown
Contributor

内容

收录 moodycamel::ConcurrentQueue 1.0.5(cameron314/concurrentqueue)为 compat.concurrentqueue

  • 形态:B(header-only) —— 三个公开头(concurrentqueue.h / blockingconcurrentqueue.h / lightweightsemaphore.h)都在 tarball 根,include_dirs = {"*"} + anchor TU 即整包;消费者按上游 README 的写法 #include <concurrentqueue.h>
  • feature:c-api(默认关闭) —— 包里唯一可编译的可选组件:c_api/ 的两个 extern "C" 封装 TU(compat.cjson utils 先例)。tests/benchmarks/ 自带 main(),lib 目标不能收(对象会急切进入消费者链接)。
  • Windows 的 MOODYCAMEL_STATIC 双侧声明 —— C API 头未被告知时按 __declspec(dllimport) 声明,对包自身 TU(要定义函数;cflags 到不了 .cpp,故用 cxxflags)与静态库消费者(feature 的接口 defines)都不成立。宏只在 #ifdef _WIN32 内被读,linux/macos 上无效。
  • License:双许可 {"BSD-2-Clause", "BSL-1.0"}
  • CN 镜像:本机无 GITCODE_TOKEN,按回退方案用纯字符串 upstream url,mcpp-res/concurrentqueue 留待维护者补充;mirror-cn-reachable 对纯字符串 url 无新校验项。
  • sha256:4d6368a27492d86011fde5ca0cf386dce7c49cd425aa3d9b063ca6ec373a6ef3(连算两次一致)。

测试成员

  • tests/examples/concurrentqueue:单线程 FIFO、bulk 往返、ProducerToken、move-only 元素、阻塞消费者(空队列 wait_dequeue_timed 必须真的等满 50ms)、4×4 MPMC 竞争下逐值「恰好一次」。
  • tests/examples/concurrentqueue-c-api:长式声明 features = ["c-api"],整数经 void* 往返校验和比对(cq 与 bcq 句柄都是 void*,装错队列会在这里暴露)。

验证

  • mcpp test -p concurrentqueuetest result ok(冷启动)
  • mcpp test -p concurrentqueue-c-apitest result ok(独立重编,feature 生效)
  • 负向验证:不开 feature 时,引用 moodycamel_cq_create 的 TU 链接默认构建对象报 undefined reference;默认构建的包对象目录里只有 anchor,无任何 c_api/*.o
  • lint 全绿(本地复现 validate.yml 各步,含 mcpp xpkg parse);compile_commands.json 确认 -DMOODYCAMEL_STATIC 到达全部四个 TU。
  • ⚠️ 本地用 mcpp 2026.8.27.1(CI 锁 2026.8.27.2;宿主访问 release CDN 超时,无法取到 .2),最终以 CI 为准。

设计文档:.agents/docs/2026-08-29-add-concurrentqueue-plan.md。目录条目落在 docs/descriptor-examples.md(+ zh)的「header-only (with features)」行 —— README 在 #277 后不再承载逐包目录。

🤖 Generated with Claude Code

moodycamel::ConcurrentQueue — the lock-free MPMC queue, plus its blocking
sibling and a flat C API over both. Shape B (header-only): the three public
headers sit at the tarball root, so `include_dirs = {"*"}` plus an anchor TU
is the package; consumers write `#include <concurrentqueue.h>` exactly as
upstream's README shows.

The one compilable optional component — `c_api/`'s two extern "C" wrapper
TUs — sits behind a default-off `c-api` feature (the compat.cjson `utils`
precedent). Windows needs `MOODYCAMEL_STATIC` on BOTH sides: the header
defaults to `__declspec(dllimport)`, which is wrong for the package's own
TUs (they define the functions, and `cflags` never reaches a .cpp — hence
`cxxflags`) and for a static-archive consumer (hence the feature's
interface `defines`). The macro is only read under `#ifdef _WIN32`, so
defining it everywhere is inert on linux/macos. Verified in the emitted
compile_commands.json that all four TUs carry it.

Tests: tests/examples/concurrentqueue asserts FIFO order, bulk round-trips,
move-only elements, a blocking consumer that REALLY waits (empty-queue
wait_dequeue_timed must burn its 50ms timeout), and a 4x4 MPMC race checked
for exact-once delivery. tests/examples/concurrentqueue-c-api consumes the
feature and round-trips integers through the void* C API. Both members
register in the workspace manifest.

Verified locally with mcpp 2026.8.27.1 (CI pins 2026.8.27.2; the release
CDN times out from this host): both members green from cold; the gate is
real — a TU referencing moodycamel_cq_create against the default build
fails to LINK (undefined reference), and the default build's object dir
holds the anchor alone. No CN mirror: no GITCODE_TOKEN on this host, so the
descriptor uses the plain-string upstream url fallback and the descriptor
catalog entry lands in docs/descriptor-examples.md (+ zh), per the post-mcpplibs#277
README layout.

Co-Authored-By: Claude <noreply@anthropic.com>
@Sunrisepeak
Sunrisepeak merged commit 6248191 into mcpplibs:main Aug 29, 2026
20 of 21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants