Struct TcpManager

Source
pub struct TcpManager { /* private fields */ }
Expand description

A manager for “shared” resources, used by mtcp_rs::TcpListener and mtcp_rs::TcpStream

The same mtcp_rs::TcpManager instance can be shared by multiple mtcp_rs::TcpListener and mtcp_rs::TcpStream instances. However, an mtcp_rs::TcpManager instance can not be shared across the thread boundary: Each thread needs to create its own mtcp_rs::TcpManager instance. A thread-local singleton instance can be obtained via the instance() function.

The canceller() function can be used to obtain a new mtcp_rs::TcpCanceller instance for this mtcp_rs::TcpManager.

Implementations§

Source§

impl TcpManager

Source

pub fn instance() -> Result<Rc<Self>>

Get the thread-local singleton TcpManager instance for the calling thread. The instance is created lazily for each thread.

Source

pub fn new() -> Result<Self>

Create a new TcpManager instance with default queue capacity.

Source

pub fn with_capacity(capacity: usize) -> Result<Self>

Create a new TcpManager instance with the specified queue capacity.

Source

pub fn canceller(&self) -> Result<TcpCanceller>

Create a new mtcp_rs::TcpCanceller instance for this TcpManager.

Source

pub fn cancelled(&self) -> bool

Check whether this TcpManager instance has been cancelled yet.

Returns true, if cancellation has been requested for this TcpManager; or false otherwise.

Source

pub fn restart(&self) -> Result<bool>

Restart the TcpManager, i.e. clear its “cancellation” status.

Returns true, if the TcpManager was restarted successfully; or false, if the TcpManager was not in a “cancelled” state.

Trait Implementations§

Source§

impl Debug for TcpManager

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.