Expand description
§A library for programming stackful coroutines in Rust.
mco is a high-performant library for programming stackful coroutines with which you can easily develop and maintain massive concurrent programs. It can be thought as the Rust version of the popular Goroutine.
§Features
- The stackful coroutine’s implementation is based on generator;
- Support schedule on a configurable number of threads for multi-core systems;
- Support coroutine’s version of a local storage ([CLS][cls]);
- Support efficient asynchronous network I/O;
- Support efficient timer management;
- Support standard synchronization primitives, a semaphore, an MPMC channel, etc;
- Support cancellation of coroutines;
- Support graceful panic handling that will not affect other coroutines;
- Support scoped coroutine creation;
- Support general selection for all the coroutine’s API;
- All the coroutine’s API are compatible with the standard library semantics;
- All the coroutine’s API can be safely called in multi-threaded context;
- Both stable, beta, and nightly channels are supported;
- Both x86_64 GNU/Linux, x86_64 Windows, x86_64 Mac OS are supported.
Re-exports§
pub extern crate generator as mco_gen;
Modules§
Macros§
- chan
- create an channel(mpmc) for example:
- co
- macro used to spawn a coroutine
- coroutine_
local - A macro to create a
static
of typeLocalKey
- cqueue_
add - macro used to create the select coroutine that will run in a infinite loop, and generate as many events as possible
- cqueue_
add_ oneshot - macro used to create the select coroutine that will run only once, thus generate only one event use mco::select;
- defer
- Defers evaluation of a block of code until the end of the scope. Sort of LIFO(last-in, first-out queue) If you encounter references to resources that cannot mut more than 2 times, try nesting RefCell and then use.borrow() and.borrow_mut().
- err
- mco::std::errors::Error
- join
- macro used to join all scoped sub coroutines for example:
- select
- macro used to select for only one event it will return the index of which event happens first for example:
- select_
token - macro used to select for only one event it will return the index of which event happens first for example:
- spawn
- macro used to spawn a coroutine
- spawn_
blocking - will spawn a thread to doing and return value by channel for example:
- spawn_
with - macro used to spawn a coroutine with options such as name, stack_size.
Structs§
Functions§
- config
- get the may configuration instance