Struct bolic_network::hub::Driver
source · pub struct Driver(/* private fields */);Expand description
Driver keeps a pool of workers with their own event loops to drive the attached endpoints. Each worker is an OS-level thread that runs an event loop dedicated to driving the asynchronous I/O of the transports owned by endpoints. Each endpoint belongs to one worker at a time (can be moved to another worker by Endpoint::set_worker). Users can use endpoints as if they are local channels without thinking about how data are actually moved to the network, and also benefit from the multi-core capability of the host machine.
Implementations§
source§impl Driver
impl Driver
pub fn new(nworker: usize) -> Result<Self, DriverError>
pub fn new_with_spawner( nworker: usize, spawner: AsyncSpawner ) -> Result<Self, DriverError>
pub async fn create_endpoint_with_options( &self, renew_once: bool ) -> Result<Endpoint, DriverError>
pub async fn create_endpoint(&self) -> Result<Endpoint, DriverError>
pub fn worker(&self, wid: usize) -> Result<Worker, DriverError>
pub fn spawner(&self) -> &AsyncSpawner
pub fn nendpoints(&self) -> usize
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Driver
impl !RefUnwindSafe for Driver
impl Send for Driver
impl Sync for Driver
impl Unpin for Driver
impl !UnwindSafe for Driver
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more