https://github.com/eldment/win-async
⏳ C++17 Concurrent Programming Implementation
https://github.com/eldment/win-async
async concurrency concurrent-programming coroutines cpp17 cxx17 modern-cpp
Last synced: 11 months ago
JSON representation
⏳ C++17 Concurrent Programming Implementation
- Host: GitHub
- URL: https://github.com/eldment/win-async
- Owner: ELDment
- License: gpl-3.0
- Created: 2025-07-12T16:08:26.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-07-20T03:38:11.000Z (11 months ago)
- Last Synced: 2025-07-20T04:46:09.610Z (11 months ago)
- Topics: async, concurrency, concurrent-programming, coroutines, cpp17, cxx17, modern-cpp
- Language: C++
- Homepage: https://github.com/ELDment/Win-Async
- Size: 36.1 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 💻 Win-Async
[简体中文项目介绍](README.zh-CN.md)
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
## ✨ Core Features
- 🚀 **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
- 💻 **Modern Asynchronous API (`Task`/`Await`)**
- 💡 **Synchronous-Style Coding**: Write asynchronous logic that reads like synchronous code using `CreateTask` and `Await`
- 🎁 **Seamless Result & Exception Propagation**: `Task` transparently delivers results or exceptions from any coroutine (whether an I/O coroutine or a thread pool task) to the caller
- 🛡️ **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`
## 🔧 How It Works
- **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
## 🛠️ Quick Start
### Using xmake
```powershell
# Configure build options (Release mode)
xmake f -m release
# Build the project
xmake
# Run the benchmark
xmake run benchmark
```
### Using CMake
```powershell
# 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
```
## 🗺️ TODO
### 🚀 Cpp-Coroutine Development Roadmap
| Priority | Category | Key Tasks |
| :---: | :--- | :--- |
| ⚡⚡ | **Fiber-based Task/Await** | [√] Design `Task`
[√] 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`) |