1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
* mtcp - TcpListener/TcpStream *with* timeout/cancellation support
* This is free and unencumbered software released into the public domain.
*/
use Result;
use Arc;
use crateFlag;
/// A canceller that can be used to abort "pending" I/O operations
///
/// Each `mtcp_rs::TcpCanceller` instance is tied to an
/// [`mtcp_rs::TcpManager`](crate::TcpManager) instance. Calling the
/// [`cancel()`](TcpCanceller::cancel()) function will *immediately* abort
/// ***any*** pending I/O operations in ***all***
/// [`mtcp_rs::TcpListener`](crate::TcpListener) or
/// [`mtcp_rs::TcpStream`](crate::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`](crate::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.