Skip to content

M1KUS3Q/pheme

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

🏛️ Pheme

Pheme is a C++20 asynchronous runtime designed for systems supporting the kqueue event notification interface. It provides a framework for managing non-blocking I/O and concurrent tasks through C++ coroutines.

System Model

The library operates on a hybrid model that separates I/O multiplexing from CPU-bound execution:

  • Event Loop: The AsyncContext utilizes a kqueue file descriptor to monitor socket readiness and internal notifications via a wakeup pipe.
  • Coroutine Integration: Standard socket operations—accept, read, and write—are wrapped in custom awaiters that suspend the calling coroutine until the kernel signals readiness.
  • Task Offloading: For functions that would otherwise block the event loop, spawn_blocking moves the execution to a ThreadPool and resumes the coroutine once the result is available.
  • Resource Management: The TcpSocket and AsyncTask classes use RAII to manage file descriptor lifetimes and coroutine state cleanup.

Current Implementation Details

  • Platform Support: Uses sys/event.h, limiting compatibility to BSD-derived systems like macOS.
  • I/O Handling: Uses EV_ONESHOT for event registrations, requiring re-registration for subsequent I/O operations.
  • Concurrency: Employs a Scheduler with a thread-safe task queue to distribute work among background threads.
  • Error Propagation: Exceptions within asynchronous tasks are captured and re-thrown upon coroutine resumption.

About

A lightweight, C++20 coroutine-driven async runtime for BSD/macOS using the Reactor-Worker pattern and kqueue.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors