Skip to content

Commit 7a172b7

Browse files
Replace Windows SuspendThread/SetThreadContext with atomic-flag preemption
Remove assembly stubs, CONTEXT constants, SuspendThread/GetThreadContext/ SetThreadContext/ResumeThread, and DuplicateHandle. Instead, the monitor thread sets an AtomicBool flag per coroutine, and the EventLoop thread checks it via Monitor::check_preempt() in the syscall facade. On Unix: unchanged — SIGURG asynchronously interrupts the thread. On Windows: cooperative — flag checked at syscall boundaries (every hooked Sleep/recv/send/etc triggers a check). Pure CPU-bound loops without syscalls cannot be preempted on Windows. Also gate coroutine_preemptive test (which uses `loop {}`) to Unix only, since a pure CPU loop can't be cooperatively preempted. Agent-Logs-Url: https://github.com/acl-dev/open-coroutine/sessions/b1d08a87-9c5f-425c-b298-4835c4bb2bce Co-authored-by: loongs-zhang <38336731+loongs-zhang@users.noreply.github.com>
1 parent 56089c8 commit 7a172b7

3 files changed

Lines changed: 48 additions & 300 deletions

File tree

0 commit comments

Comments
 (0)