Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ellectroid/asynceventhandler_basic

Asynchronous single-threaded event handler
https://github.com/ellectroid/asynceventhandler_basic

async asynchronous event event-driven event-handling event-management fifo function-pointers queue semaphore thread threads

Last synced: about 22 hours ago
JSON representation

Asynchronous single-threaded event handler

Awesome Lists containing this project

README

        

# AsyncEventHandler_Basic
Asynchronous single-threaded event handler

For demonstration purposes only

AsyncEventHandler implementation
Dialect: C++20 (uses \)

Properties:
- 1 thread, sleeps when idle
- 1 externally provided event handler function for all events
- 1 externally provided event parameter buffer of user-defined size
- 4 handler function parameters individual to every event
- 1 externally provided queue of events of user-defined size
- Binds event ID number to a set of parameters for the handler
- Events triggered using event number
- Supports negative event numbers (for example, for error handling events)
- Activate/deactivate handler execution on per-event and global level
- Diverse error codes in case something goes wrong
- Trivially destructible
- Buffer memory and a thread object are provided externally (doesn't manage object lifetime of anything)
- You can change internal pointers at runtime if you're into that sort of thing
- It actually seems to work

Includes a test function with detailed explanation and example of setup, use and error handling.