Skip to content

Add single-threaded (lockless) mode to IOCP backend#225

Open
mvandeberg wants to merge 1 commit intocppalliance:developfrom
mvandeberg:pr/iocp-lockless
Open

Add single-threaded (lockless) mode to IOCP backend#225
mvandeberg wants to merge 1 commit intocppalliance:developfrom
mvandeberg:pr/iocp-lockless

Conversation

@mvandeberg
Copy link
Copy Markdown
Contributor

@mvandeberg mvandeberg commented Apr 6, 2026

Summary by CodeRabbit

  • New Features
    • Added single-threaded mode configuration to optimize performance by disabling synchronization overhead when cross-thread operations are not required.
    • Added runtime control over synchronization behavior in the scheduler for improved efficiency in single-threaded contexts.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 6, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 173882ef-c54c-4d7c-b6b1-9ef3496e47f2

📥 Commits

Reviewing files that changed from the base of the PR and between 9c7d1eb and 5b2feeb.

📒 Files selected for processing (3)
  • include/boost/corosio/native/detail/iocp/win_mutex.hpp
  • include/boost/corosio/native/detail/iocp/win_scheduler.hpp
  • src/corosio/src/io_context.cpp

📝 Walkthrough

Walkthrough

The pull request adds runtime enable/disable control to a Windows critical section wrapper class (win_mutex) and introduces single-threaded mode configuration for the Windows IOCP scheduler (win_scheduler). When disabled, mutex operations become no-ops; the scheduler can disable locking entirely in single-threaded mode. Configuration propagates from io_context to the scheduler, which controls mutex behavior.

Changes

Cohort / File(s) Summary
Windows Mutex Control
include/boost/corosio/native/detail/iocp/win_mutex.hpp
Added set_enabled(bool) and enabled() const methods with new enabled_ boolean member to allow runtime control of lock behavior; when disabled, lock() and unlock() skip EnterCriticalSection/LeaveCriticalSection calls, and try_lock() returns true immediately.
Windows Scheduler Configuration
include/boost/corosio/native/detail/iocp/win_scheduler.hpp
Added configure_single_threaded(bool) method that sets internal flag and delegates mutex control to dispatch_mutex_.set_enabled(), disabling dispatch synchronization in single-threaded mode.
IO Context Scheduler Setup
src/corosio/src/io_context.cpp
Updated apply_scheduler_options to invoke configure_single_threaded(true) on IOCP schedulers when single-threaded mode is requested, extending existing reactor-only behavior to Windows platform.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Poem

🐰 A mutex learns to rest its weary brain,
No locks when single-threaded reigns,
The scheduler whispers, "peace, no strain,"
One thread, one path, no concurrent pain! 🔓

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding single-threaded (lockless) mode support to the IOCP backend through new configuration methods and runtime enable/disable control.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@cppalliance-bot
Copy link
Copy Markdown

An automated preview of the documentation is available at https://225.corosio.prtest3.cppalliance.org/index.html

If more commits are pushed to the pull request, the docs will rebuild at the same URL.

2026-04-06 18:57:06 UTC

@cppalliance-bot
Copy link
Copy Markdown

GCOVR code coverage report https://225.corosio.prtest3.cppalliance.org/gcovr/index.html
LCOV code coverage report https://225.corosio.prtest3.cppalliance.org/genhtml/index.html
Coverage Diff Report https://225.corosio.prtest3.cppalliance.org/diff-report/index.html

Build time: 2026-04-06 19:06:52 UTC

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.

2 participants