Struct asyncio::IoService
[−]
[src]
pub struct IoService(_);
Provides core I/O functionality.
Methods
impl IoService
[src]
fn new() -> IoService
Returns a new IoService
.
Panics
Panics if too many open files.
Examples
use asyncio::IoService; let io = IoService::new();
fn dispatch<F>(&self, func: F) where F: FnOnce(&IoService) + Send + 'static
Requests a process to invoke the given handler.
Examples
use asyncio::IoService; use std::sync::atomic::{Ordering, AtomicUsize, ATOMIC_USIZE_INIT}; static COUNT: AtomicUsize = ATOMIC_USIZE_INIT; let io = IoService::new(); io.dispatch(|_| { COUNT.fetch_add(1, Ordering::SeqCst); }); io.dispatch(|_| { COUNT.fetch_add(1, Ordering::SeqCst); }); io.dispatch(|_| { COUNT.fetch_add(1, Ordering::SeqCst); }); io.run(); assert_eq!(COUNT.load(Ordering::Relaxed), 3);
fn post<F>(&self, func: F) where F: FnOnce(&IoService) + Send + 'static
Requests a process to invoke the given handler and return immediately.
Examples
use asyncio::IoService; use std::sync::atomic::{Ordering, AtomicUsize, ATOMIC_USIZE_INIT}; static COUNT: AtomicUsize = ATOMIC_USIZE_INIT; let io = IoService::new(); io.post(|_| { COUNT.fetch_add(1, Ordering::SeqCst); }); io.post(|_| { COUNT.fetch_add(1, Ordering::SeqCst); }); io.post(|_| { COUNT.fetch_add(1, Ordering::SeqCst); }); io.run(); assert_eq!(COUNT.load(Ordering::Relaxed), 3);
fn reset(&self)
Resets a stopped IoService
.
Examples
use asyncio::IoService; let io = IoService::new(); assert_eq!(io.stopped(), false); io.stop(); assert_eq!(io.stopped(), true); io.reset(); assert_eq!(io.stopped(), false);
fn run(&self)
fn stop(&self)
Sets a stop request and cancel all of the waiting event in an IoService
.
Examples
use asyncio::IoService; let io = IoService::new(); io.stop();
fn stopped(&self) -> bool
Returns true if this has been stopped.
Examples
use asyncio::IoService; let io = IoService::new(); assert_eq!(io.stopped(), false); io.stop(); assert_eq!(io.stopped(), true);
fn work(io: &IoService) -> IoServiceWork
Returns a IoServiceWork
associated the IoService
.
Examples
use asyncio::IoService; let io = IoService::new(); let mut work = Some(IoService::work(&io)); assert_eq!(io.stopped(), false); work = None; assert_eq!(io.stopped(), true);
fn strand<T, F>(io: &IoService, data: T, init: F) where F: FnOnce(Strand<T>)
fn spawn<F>(io: &IoService, func: F) where F: FnOnce(&Coroutine) + Send + 'static
Trait Implementations
impl Clone for IoService
[src]
fn clone(&self) -> IoService
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl Debug for IoService
[src]
impl IoObject for IoService
[src]
fn io_service(&self) -> &IoService
Returns a IoService
associated with this object.