Expand description
§Mioco
Scalable, coroutine-based, asynchronous IO handling library for Rust programming language.
Mioco uses asynchronous event loop, to cooperatively switch between
coroutines (aka. green threads), depending on data availability. You
can think of mioco
as of Node.js for Rust or Rust green
threads on top of mio
.
Mioco API mimics Rust standard library threading API, so it’s easy convert existing code to Mioco.
Mioco coroutines should not use any native blocking-IO operations. Any
long-running operations, or blocking IO should be executed in
mioco::offload()
blocks.
§ Features:
* multithreading support; (see `Config::set_thread_num()`)
* timers (see `timer` module);
* coroutine exit notification (see `JoinHandle`).
* synchronous operations support (see `mioco::offload()`).
* synchronization primitives (see `sync` module):
* channels (see `sync::mpsc::channel()`);
* support for synchronization with native environment (outside of Mioco instance)
* user-provided scheduling; (see `Config::set_scheduler()`);
§ Example:
See examples/echo.rs
for an example TCP echo server
Modules§
- mio
- Some mio types that are part of mioco-API, re-exported
- sched
- Custom scheduling
- sync
- Useful synchronization primitives
- tcp
- TCP
- timer
- Timers
- udp
- UDP
- unix
- Unix sockets IO
Macros§
- select
- Select operation on multiple IO.
Structs§
- Config
- Mioco instance builder.
- Event
- Event delivered to the coroutine
- Event
Source Id - Id of an event source used to enumerate them.
- Handler
- Mioco event loop
Handler
- Join
Handle - Allows to join on mioco Coroutine
- MioAdapter
- Adapt raw
mio
type to miocoEvented
requirements. - Mioco
- Mioco instance.
- RW
- Read/Write/Both/None
- RcEvent
Source - To share the data between coroutine itself and the coroutine internals
referring to the blocked event sources,
RcEventSource
is being used.
Traits§
- Event
Source Trait - Trait for coroutine event source
- Evented
- Mioco event source.
- Evented
Impl - Utility trait that simplifies implementing
Evented
Functions§
- get_
userdata - Get user-provided data of the current coroutine.
- in_
coroutine - Check if running inside a mioco coroutine.
- offload
- Execute a block of blocking operations outside of mioco.
- select_
wait - Block the current coroutine waiting for an event.
- set_
children_ userdata - Set user-provided data for future child coroutines.
- set_
userdata - Set user-provided data for the current coroutine.
- shutdown
- Shutdown current mioco instance.
- sleep
- Block execution for a given time.
- sleep_
ms - Block execution for a given time.
- spawn
- Spawn a mioco coroutine that executes the given function.
- start
- Start a new mioco instance.
- start_
threads - Start a new mioco instance with a given number of threads.
- thread_
num - Get number of threads of current mioco instance.
- yield_
now - Yield execution of the current coroutine.