A C++ coroutine library implemented based on Windows Fiber
, VEH
, IOCP
, and C++17
⚠️ This is a learning project aimed at exploring the underlying mechanisms of coroutine scheduling, context switching, and exception handling. Since the core implementation relies on Windows Fiber, this project only supports the Windows platform. Additionally, this project does not provide production-level performance optimizations or long-term community support
-
🚀 Powerful Hybrid Scheduling Model
- 🤝 Cooperative I/O Coroutines: Integrates
IOCP
to elegantly handle high-concurrency, non-blocking I/O operations - ⚡ Parallel CPU-Bound Tasks: A built-in thread pool allows offloading high-latency tasks via
RunOnThreadPool
, preventing them from blocking the main I/O event loop
- 🤝 Cooperative I/O Coroutines: Integrates
-
💻 Modern Asynchronous API (
Task
/Await
)- 💡 Synchronous-Style Coding: Write asynchronous logic that reads like synchronous code using
CreateTask
andAwait
- 🎁 Seamless Result & Exception Propagation:
Task<T>
transparently delivers results or exceptions from any coroutine (whether an I/O coroutine or a thread pool task) to the caller
- 💡 Synchronous-Style Coding: Write asynchronous logic that reads like synchronous code using
-
🛡️ Robust Exception Safety
- 📦 Unified Exception Handling: Automatically captures exceptions from any context (Fiber or thread pool) using Vectored Exception Handling (VEH) and safely propagates them through the
Promise
- 📦 Unified Exception Handling: Automatically captures exceptions from any context (Fiber or thread pool) using Vectored Exception Handling (VEH) and safely propagates them through the
- Context Switching: Based on the Windows
Fiber
API - Exception Handling: Utilizes Vectored Exception Handling (
VEH
) - Scheduling Loop: An IOCP-driven event loop that unifies coroutine scheduling, timers, and asynchronous I/O events
# Configure build options (Release mode)
xmake f -m release
# Build the project
xmake
# Run the benchmark
xmake run benchmark
# Create and enter the build directory
mkdir build; cd build
# Generate the build system
cmake ..
# Build the project (Release mode)
cmake --build . --config Release
# Run the benchmark
./Release/benchmark.exe
Priority | Category | Key Tasks |
---|---|---|
⚡⚡ | Fiber-based Task/Await | [√] Design Task<T> [√] Implement Await |
⚡⚡⚡⚡ | Scheduler & Concurrency | [√] Multi-threaded scheduler [√] Integrate IOCP |
⚡⚡ | Coroutine Sync Primitives | [ ] Async Mutex (AsyncMutex )[ ] Async Semaphore ( AsyncSemaphore )[ ] Combinators ( WhenAll / WhenAny ) |
⚡ | API | [ ] Cooperative Cancellation (CancellationToken ) |