Struct mioco::Config
[−]
[src]
pub struct Config { /* fields omitted */ }
Mioco instance builder.
Methods
impl Config
[src]
fn new() -> Self
Create mioco Config
.
Use it to configure mioco instance.
See start()
and start_threads()
for convenience wrappers.
fn set_thread_num(&mut self, thread_num: usize) -> &mut Self
Set numer of threads to run mioco with
Default is equal to a numer of CPUs in the system.
fn set_scheduler(&mut self, scheduler: Box<Scheduler + 'static>) -> &mut Self
Set custom scheduler.
See Scheduler
trait.
Default is a simple FIFO-scheduler that spreads all the new coroutines between all threads in round-robin fashion, and runs them in FIFO manner.
See private FifoSchedule
source for details.
unsafe fn set_stack_size(&mut self, stack_size: usize) -> &mut Self
Set stack size in bytes.
Default is 2MiB.
Should be a power of 2.
Stack size includes a protection page. Setting too small stack will lead to SEGFAULTs. See context-rs stack.rs for implementation details. The sane minimum seems to be 128KiB, which is two 64KB pages.
fn set_userdata<T: Any + Send + Sync>(&mut self, data: T) -> &mut Self
Set user-provided data for the first coroutine
See set_userdata
.
fn event_loop(&mut self) -> &mut EventLoopConfig
Configure mio::EvenLoop
for all the threads
fn set_catch_panics(&mut self, catch_panics: bool) -> &mut Self
Set if this instance will be catching panics, that occur within the coroutines
- If true mioco will gracefully handle panics inside coroutines. (default)
- If false any panic inside coroutine will panic the whole mioco instance.
unsafe fn set_stack_protection(&mut self, stack_protection: bool) -> &mut Self
Set if this instance should use protected stacks (default).
Unprotected stacks can be used to skip creation of stack guard page. This is useful when hitting OS limits regarding process mappings. It's better idea to fix it at the OS level, but eg. for automated testing it might be useful.