Skip to content

Latest commit

 

History

History
32 lines (17 loc) · 1.46 KB

README.md

File metadata and controls

32 lines (17 loc) · 1.46 KB

Somnus

Somnus is a co-operative threading support library (See: Fiber).

Fibers are a powerful concurrency tool that prevents unnecessary blocking and operating system thread context switching. It's not a panacea, but it is a useful tool which, utilized in the proper way, yields massive performance gains.

Refer to the wiki for type and function documentation.

Channel Examples

The canonical example of any coroutine based model is an example with a channel. The following two examples show the use of a channel for both pointer types and non-pointer types.

Non pointer type example

Pointer type example

std::shared_ptr type example

Event Dispatch Examples

An event dispatcher class is supplied along with the other functionality of the library. It uses Ropes internally based upon a configuration loaded from a file.

Event Dispatcher Example

Configuration File Example

Other Examples

Long running tasks prevent other tasks from doing useful work, including initiation of long running operations. To prevent this, long running tasks should carefully place calls to defer() which switches to other waiting tasks, if needed. Execution will resume after all other waiting tasks have had an opportunity to run.

Defer Functionality