1717
1818> [ !IMPORTANT]
1919> CMP provides a lazy, single-consumer ` Task<T> ` / ` Task<void> ` and a caller-thread ` RunLoop `
20- > with explicit scheduling. Cancellation, timers, asynchronous I/O, and detached execution are
21- > not implemented.
20+ > with explicit and monotonic timed scheduling. Cancellation, asynchronous I/O, and detached
21+ > execution are not implemented.
2222
2323CMP is being built as a modern coroutine runtime and library on standard stackless C++
24- coroutines. The intended direction is an explicit ` co_await ` model that can grow, in small
25- verified steps, toward scheduling, timers, asynchronous I/O, cancellation, and safe handling of
26- blocking work.
24+ coroutines. Its explicit ` co_await ` model now covers scheduling and monotonic timers and can grow,
25+ in small verified steps, toward asynchronous I/O, cancellation, and safe handling of blocking
26+ work.
2727
2828## Why CMP?
2929
@@ -48,7 +48,7 @@ promise that:
4848- a task is automatically equivalent to a Go goroutine;
4949- an arbitrary blocking call becomes non-blocking;
5050- coroutine switching is safe directly inside a signal handler;
51- - M: N scheduling, work stealing, timers, cancellation, or async I/O already exist.
51+ - M: N scheduling, work stealing, cancellation, or async I/O already exist.
5252
5353Those capabilities must be designed and verified individually. The expected direction is
5454explicit async I/O awaiters, a dedicated blocking pool, and cooperative safe points.
@@ -72,9 +72,10 @@ cd examples/basic
7272mcpp run
7373```
7474
75- The example prints ` Coroutine result: 42 ` from inside a scheduled ` Task<void> ` coroutine and exits
76- successfully. It proves that an independent mcpp package can resolve the path dependency, import
77- ` mcpplibs.cmp ` , compose Tasks, and drive them through the public RunLoop.
75+ The example waits for a short RunLoop timer, prints ` Coroutine result: 42 ` from inside a
76+ ` Task<void> ` coroutine, and exits successfully. It proves that an independent mcpp package can
77+ resolve the path dependency, import ` mcpplibs.cmp ` , compose Tasks, and use timed scheduling through
78+ the public RunLoop.
7879
7980## Current API
8081
@@ -85,12 +86,14 @@ import mcpplibs.cmp;
8586using mcpplibs::cmp::Task;
8687using mcpplibs::cmp::RunLoop;
8788
89+ using namespace std ::chrono_literals;
90+
8891Task<int > answer() {
8992 co_return 42;
9093}
9194
9295Task<void > print_answer(RunLoop::Scheduler scheduler) {
93- co_await scheduler.schedule( );
96+ co_await scheduler.schedule_after(10ms );
9497 auto value = co_await answer();
9598 std::println("Coroutine result: {}", value);
9699 co_return;
@@ -114,9 +117,11 @@ library.
114117
115118`RunLoop::run()` consumes one root Task, executes ready coroutines on the calling thread, returns
116119its value, and rethrows its exception. `Scheduler::schedule()` always suspends and queues the
117- continuation. Scheduler handles are copyable, but remain tied to their originating RunLoop.
118- Sequential `run()` calls are supported; nested or concurrent calls are rejected. A moved-from Task
119- must not be awaited.
120+ continuation. `schedule_after()` waits for a relative `steady_clock` duration, while
121+ `schedule_at()` waits for an absolute steady-clock time point; expiry makes work eligible and
122+ never resumes it inline. Scheduler handles are copyable, but remain tied to their originating
123+ RunLoop. Sequential `run()` calls are supported; nested or concurrent calls are rejected. A
124+ moved-from Task must not be awaited.
120125
121126RunLoop is not a background thread and does not make blocking code asynchronous. A Task that
122127suspends without arranging a future resume can leave `run()` waiting indefinitely. CMP does not
@@ -166,7 +171,7 @@ Runtime work is split into independently reviewable phases:
1661711 . package identity and importable-module bootstrap — implemented;
1671722 . coroutine task and lifetime semantics — initial ` Task ` implemented;
1681733 . a root runner and minimal single-thread scheduler — initially implemented;
169- 4 . timers, cancellation, and structured wake-up paths;
174+ 4 . monotonic Timer v1 — implemented; cancellation and structured wake-up paths remain ;
1701755 . multi-worker scheduling and work stealing;
1711766 . asynchronous I/O integration and a blocking pool.
172177
0 commit comments