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
impl TcpManager
Sourcepub fn instance() -> Result<Rc<Self>>
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.
Sourcepub fn with_capacity(capacity: usize) -> Result<Self>
pub fn with_capacity(capacity: usize) -> Result<Self>
Create a new TcpManager
instance with the specified queue capacity.
Sourcepub fn canceller(&self) -> Result<TcpCanceller>
pub fn canceller(&self) -> Result<TcpCanceller>
Create a new mtcp_rs::TcpCanceller
instance
for this TcpManager
.