pub struct TcpCanceller { /* private fields */ }Expand description
A canceller that can be used to abort “pending” I/O operations
Each mtcp_rs::TcpCanceller instance is tied to an
mtcp_rs::TcpManager instance. Calling the
cancel() function will immediately abort
any pending I/O operations in all
mtcp_rs::TcpListener or
mtcp_rs::TcpStream instances that are tied to the same
mtcp_rs::TcpManager instance. Unlike the mtcp_rs::TcpManager instance, the
mtcp_rs::TcpCanceller instance can be moved across the thread boundary.
This is useful, for example, to implement a Ctrl+C (SIGINT) handler.
Cancelled I/O operations will fail with an
TcpError::Cancelled error. However, there
is no guarantee that I/O operations already in progress will actually
be cancelled! Even after cancellation has been requested, an I/O operation
that was just about to finish may still succeed, or even fail with a
different error. Newly started operations are guaranteed to be cancelled.