Skip to content

Commit 47918bb

Browse files
committed
feat: implement coroutine RunLoop and Scheduler
Add caller-thread FIFO scheduling, cross-thread wakeups, root result and exception handling, boundary tests, examples, documentation, and current mcpp configuration.
1 parent 7e24ee0 commit 47918bb

26 files changed

Lines changed: 1437 additions & 816 deletions

.agents/skills/mcpp-index/SKILL.md

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,26 +29,25 @@ mcpp index list|add|remove|update # manage registries
2929
Package identity is a pair: **`namespace` is a dotted hierarchical path, `name` is a single
3030
atomic segment** (`compat` + `zlib`, `mcpplibs.capi` + `lua` — never `mcpplibs` + `capi.lua`).
3131

32-
A **bare** dependency name resolves in exactly three places, in order:
33-
34-
1. `mcpplibs` — the default namespace
35-
2. `compat` — third-party C/C++ wrappers
36-
3. packages that declare no namespace at all
37-
38-
Anything else must be spelled out — there is no index-wide fuzzy search by short name:
32+
A **bare** dependency name means the `mcpplibs` default namespace. The older fallback search
33+
through `compat` and packages without a namespace is deprecated in mcpp 2026.8 and removed in
34+
2026.9. Every other namespace must be spelled out; there is no index-wide fuzzy search by short
35+
name:
3936

4037
```toml
4138
[dependencies]
4239
"chriskohlhoff.asio" = "1.38.1" # dotted selector
4340

4441
[dependencies.chriskohlhoff] # or a namespace sub-table
4542
asio = "1.38.1"
43+
44+
[dependencies.compat] # third-party wrapper
45+
zlib = "1.3.1"
4646
```
4747

48-
When resolution fails: read the error (it lists the namespaces searched), then check the
49-
spelling against the online index, and run `xlings update` — a release tarball bundles an
50-
index snapshot frozen at build time, which is the usual reason a fresh version "does not
51-
exist".
48+
When resolution fails: read the error, check the exact namespace and spelling against the online
49+
index, and run `xlings update` — a release tarball bundles an index snapshot frozen at build time,
50+
which is the usual reason a fresh version "does not exist".
5251

5352
Mirrors: `mcpp self config --mirror CN` switches to the GitCode mirror; `GLOBAL` (upstream) is
5453
the default.

.agents/skills/mcpp-style-ref/SKILL.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,10 @@ mcpp --version
149149

150150
- `.xlings.json`:声明项目工具环境
151151
- `mcpp.toml`:声明 `[package]` 与测试依赖;简单库目标可由 mcpp 从 `src/*.cppm` 自动推断
152-
- `src/cmp.cppm`:库主模块接口,声明 `export module mcpplibs.cmp;`
153-
- `tests/cmp_test.cpp`:`mcpp test` 自动发现的 gtest 导入测试;不要定义 `main()`
152+
- `src/cmp.cppm`:库主模块接口,导出 `:task` 与 `:run_loop` 分区
153+
- `src/task.cppm`:`Task<T>` 与 `Task<void>` 分区
154+
- `src/run_loop.cppm`:`RunLoop` 与 `Scheduler` 分区
155+
- `tests/cmp_test.cpp`、`tests/run_loop_test.cpp`:`mcpp test` 自动发现的 gtest 测试;不要定义 `main()`
154156
- `examples/basic/`:独立 mcpp consumer 包,通过 path 依赖引用根库
155157
156158
构建:

.agents/skills/mcpp/SKILL.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ The build and package tool this repository is built with. mcpp is module-first C
99
`import std` works out of the box, toolchains install into an isolated sandbox, and
1010
dependencies resolve through a package index.
1111

12-
Verified against **mcpp 2026.8.1.1**. mcpp is pre-1.0 and moves fast — when this skill and
12+
Verified against **mcpp 2026.8.11.2**. mcpp is pre-1.0 and moves fast — when this skill and
1313
the tool disagree, the tool wins. Check with `mcpp --help`, `mcpp <cmd> --help`, and the
1414
[upstream docs](https://github.com/mcpp-community/mcpp/tree/main/docs).
1515

@@ -81,12 +81,12 @@ defines = ["FOO=1"] # bare names; reach every TU including module scan
8181
default-profile = "release" # project default when no --profile/--release is passed
8282

8383
[dependencies] # runtime deps
84-
cmdline = "0.0.2" # bare name: searched in mcpplibs, then compat, then no-namespace
84+
cmdline = "0.0.2" # bare name: mcpplibs namespace
8585

8686
[dependencies.mcpplibs] # namespace sub-table (preferred for several from one org)
8787
tinyhttps = "0.2.3"
8888

89-
[dev-dependencies] # test-only; `mcpp build` ignores these
89+
[dev-dependencies.compat] # test-only; `mcpp build` ignores these
9090
gtest = "1.15.2"
9191

9292
[toolchain]
@@ -103,10 +103,10 @@ Dependency forms: `"1.2.3"` · `"^1.2"` · `"~1.2"` · `">=1.0, <2.0"` ·
103103
`{ path = "../mylib" }` · `{ git = "...", tag = "v1.0.0" }` ·
104104
`{ version = "0.0.3", features = ["docking"] }`.
105105

106-
**Namespace rule:** a bare name resolves in exactly three places, in order — `mcpplibs`,
107-
`compat` (third-party C/C++ wrappers), then packages that declare no namespace. Any other
108-
namespace must be written out: `"chriskohlhoff.asio" = "1.38.1"` or a
109-
`[dependencies.chriskohlhoff]` sub-table.
106+
**Namespace rule:** a bare name means `mcpplibs`. Compatibility fallback to `compat` is deprecated
107+
in 2026.8 and removed in 2026.9, so third-party wrappers and every other namespace must be explicit:
108+
`[dependencies.compat]`, `"chriskohlhoff.asio" = "1.38.1"`, or the corresponding namespace
109+
sub-table.
110110

111111
## Modules
112112

.agents/skills/more-details/SKILL.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,11 @@ docs, and actual command output.
3131
- `docs/architecture.md` (`.zh.md`, `.zh.hant.md`) — current structure, mcpp conventions, runtime boundaries, CI.
3232
- `.xlings.json` — the project tool environment (which mcpp version builds this).
3333
- `mcpp.toml` — package metadata, dependencies, dev-dependencies.
34-
- `src/cmp.cppm` — the import-only CMP root module interface.
35-
- `tests/cmp_test.cpp` — the gtest import smoke test.
34+
- `src/cmp.cppm` — the CMP root module interface, re-exporting its public partitions.
35+
- `src/task.cppm` — lazy single-consumer Task implementation.
36+
- `src/run_loop.cppm` — caller-thread RunLoop, Scheduler, and root driver.
37+
- `tests/cmp_test.cpp` — Task contract and lifetime tests.
38+
- `tests/run_loop_test.cpp` — scheduling, threading, and invalid-use boundary tests.
3639
- `examples/basic/` — a standalone path-dependency consumer.
3740
- `.github/workflows/ci-{linux,macos,windows}.yml` — per-platform build, test, and example CI.
3841

@@ -87,6 +90,6 @@ mcpp --version
8790
- **Confirm an `mcpp.toml` field**`mcpp.toml`, the [`mcpp`](../mcpp/SKILL.md) skill, then upstream `docs/05-mcpp-toml.md`.
8891
- **Add a dependency** → the [`mcpp-index`](../mcpp-index/SKILL.md) skill, then `mcpplibs/cmdline` for a real example.
8992
- **Add a module API**`mcpp-style-ref`, then edit `src/*.cppm`.
90-
- **Add a test** → follow `tests/cmp_test.cpp`, verify with `mcpp test`.
93+
- **Add a test** → follow the focused file under `tests/`, verify with `mcpp test`.
9194
- **Add an example** → follow `examples/basic/` — its own `mcpp.toml` with a path dependency.
9295
- **Publish the library** → the [`mcpp-index`](../mcpp-index/SKILL.md) skill.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ compile_commands.json
1010
# Local tools and editor state
1111
.cache/
1212
/.clice/
13+
/.idea/
1314
/.rpiv/
1415
/.vscode/
1516

.idea/.gitignore

Lines changed: 0 additions & 10 deletions
This file was deleted.

.idea/cmp.iml

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)