Coverage Report

Created: 2021-01-22 16:54

crossbeam-channel/src/flavors/at.rs
Line
Count
Source (jump to first uncovered line)
1
//! Channel that delivers a message at a certain moment in time.
2
//!
3
//! Messages cannot be sent into this kind of channel; they are materialized on demand.
4
5
use std::sync::atomic::{AtomicBool, Ordering};
6
use std::thread;
7
use std::time::{Duration, Instant};
8
9
use crate::context::Context;
10
use crate::err::{RecvTimeoutError, TryRecvError};
11
use crate::select::{Operation, SelectHandle, Token};
12
use crate::utils;
13
14
/// Result of a receive operation.
15
pub(crate) type AtToken = Option<Instant>;
16
17
/// Channel that delivers a message at a certain moment in time
18
pub(crate) struct Channel {
19
    /// The instant at which the message will be delivered.
20
    delivery_time: Instant,
21
22
    /// `true` if the message has been received.
23
    received: AtomicBool,
24
}
25
26
impl Channel {
27
    /// Creates a channel that delivers a message at a certain instant in time.
28
    #[inline]
29
40.8k
    pub(crate) fn new_deadline(when: Instant) -> Self {
30
40.8k
        Channel {
31
40.8k
            delivery_time: when,
32
40.8k
            received: AtomicBool::new(false),
33
40.8k
        }
34
40.8k
    }
35
    /// Creates a channel that delivers a message after a certain duration of time.
36
    #[inline]
37
40.6k
    pub(crate) fn new_timeout(dur: Duration) -> Self {
38
40.6k
        Self::new_deadline(Instant::now() + dur)
39
40.6k
    }
40
41
    /// Attempts to receive a message without blocking.
42
    #[inline]
43
46.3k
    pub(crate) fn try_recv(&self) -> Result<Instant, TryRecvError> {
44
46.3k
        // We use relaxed ordering because this is just an optional optimistic check.
45
46.3k
        if self.received.load(Ordering::Relaxed) {
46
            // The message has already been received.
47
15.8k
            return Err(TryRecvError::Empty);
48
30.5k
        }
49
30.5k
50
30.5k
        if Instant::now() < self.delivery_time {
51
            // The message was not delivered yet.
52
17.0k
            return Err(TryRecvError::Empty);
53
13.4k
        }
54
13.4k
55
13.4k
        // Try receiving the message if it is still available.
56
13.4k
        if !self.received.swap(true, Ordering::SeqCst) {
57
            // Success! Return delivery time as the message.
58
13.3k
            Ok(self.delivery_time)
59
        } else {
60
            // The message was already received.
61
0
            Err(TryRecvError::Empty)
62
        }
63
46.2k
    }
Unexecuted instantiation: <crossbeam_channel::flavors::at::Channel>::try_recv
<crossbeam_channel::flavors::at::Channel>::try_recv
Line
Count
Source
43
2.50k
    pub(crate) fn try_recv(&self) -> Result<Instant, TryRecvError> {
44
2.50k
        // We use relaxed ordering because this is just an optional optimistic check.
45
2.50k
        if self.received.load(Ordering::Relaxed) {
46
            // The message has already been received.
47
0
            return Err(TryRecvError::Empty);
48
2.50k
        }
49
2.50k
50
2.50k
        if Instant::now() < self.delivery_time {
51
            // The message was not delivered yet.
52
0
            return Err(TryRecvError::Empty);
53
2.50k
        }
54
2.50k
55
2.50k
        // Try receiving the message if it is still available.
56
2.50k
        if !self.received.swap(true, Ordering::SeqCst) {
57
            // Success! Return delivery time as the message.
58
2.50k
            Ok(self.delivery_time)
59
        } else {
60
            // The message was already received.
61
0
            Err(TryRecvError::Empty)
62
        }
63
2.50k
    }
Unexecuted instantiation: <crossbeam_channel::flavors::at::Channel>::try_recv
<crossbeam_channel::flavors::at::Channel>::try_recv
Line
Count
Source
43
38.8k
    pub(crate) fn try_recv(&self) -> Result<Instant, TryRecvError> {
44
38.8k
        // We use relaxed ordering because this is just an optional optimistic check.
45
38.8k
        if self.received.load(Ordering::Relaxed) {
46
            // The message has already been received.
47
15.8k
            return Err(TryRecvError::Empty);
48
22.9k
        }
49
22.9k
50
22.9k
        if Instant::now() < self.delivery_time {
51
            // The message was not delivered yet.
52
17.0k
            return Err(TryRecvError::Empty);
53
5.93k
        }
54
5.93k
55
5.93k
        // Try receiving the message if it is still available.
56
5.93k
        if !self.received.swap(true, Ordering::SeqCst) {
57
            // Success! Return delivery time as the message.
58
5.86k
            Ok(self.delivery_time)
59
        } else {
60
            // The message was already received.
61
0
            Err(TryRecvError::Empty)
62
        }
63
38.7k
    }
Unexecuted instantiation: <crossbeam_channel::flavors::at::Channel>::try_recv
Unexecuted instantiation: <crossbeam_channel::flavors::at::Channel>::try_recv
Unexecuted instantiation: <crossbeam_channel::flavors::at::Channel>::try_recv
<crossbeam_channel::flavors::at::Channel>::try_recv
Line
Count
Source
43
45
    pub(crate) fn try_recv(&self) -> Result<Instant, TryRecvError> {
44
45
        // We use relaxed ordering because this is just an optional optimistic check.
45
45
        if self.received.load(Ordering::Relaxed) {
46
            // The message has already been received.
47
0
            return Err(TryRecvError::Empty);
48
45
        }
49
45
50
45
        if Instant::now() < self.delivery_time {
51
            // The message was not delivered yet.
52
37
            return Err(TryRecvError::Empty);
53
8
        }
54
8
55
8
        // Try receiving the message if it is still available.
56
8
        if !self.received.swap(true, Ordering::SeqCst) {
57
            // Success! Return delivery time as the message.
58
8
            Ok(self.delivery_time)
59
        } else {
60
            // The message was already received.
61
0
            Err(TryRecvError::Empty)
62
        }
63
45
    }
Unexecuted instantiation: <crossbeam_channel::flavors::at::Channel>::try_recv
Unexecuted instantiation: <crossbeam_channel::flavors::at::Channel>::try_recv
Unexecuted instantiation: <crossbeam_channel::flavors::at::Channel>::try_recv
<crossbeam_channel::flavors::at::Channel>::try_recv
Line
Count
Source
43
2.50k
    pub(crate) fn try_recv(&self) -> Result<Instant, TryRecvError> {
44
2.50k
        // We use relaxed ordering because this is just an optional optimistic check.
45
2.50k
        if self.received.load(Ordering::Relaxed) {
46
            // The message has already been received.
47
0
            return Err(TryRecvError::Empty);
48
2.50k
        }
49
2.50k
50
2.50k
        if Instant::now() < self.delivery_time {
51
            // The message was not delivered yet.
52
0
            return Err(TryRecvError::Empty);
53
2.50k
        }
54
2.50k
55
2.50k
        // Try receiving the message if it is still available.
56
2.50k
        if !self.received.swap(true, Ordering::SeqCst) {
57
            // Success! Return delivery time as the message.
58
2.50k
            Ok(self.delivery_time)
59
        } else {
60
            // The message was already received.
61
0
            Err(TryRecvError::Empty)
62
        }
63
2.50k
    }
<crossbeam_channel::flavors::at::Channel>::try_recv
Line
Count
Source
43
2.50k
    pub(crate) fn try_recv(&self) -> Result<Instant, TryRecvError> {
44
2.50k
        // We use relaxed ordering because this is just an optional optimistic check.
45
2.50k
        if self.received.load(Ordering::Relaxed) {
46
            // The message has already been received.
47
0
            return Err(TryRecvError::Empty);
48
2.50k
        }
49
2.50k
50
2.50k
        if Instant::now() < self.delivery_time {
51
            // The message was not delivered yet.
52
0
            return Err(TryRecvError::Empty);
53
2.50k
        }
54
2.50k
55
2.50k
        // Try receiving the message if it is still available.
56
2.50k
        if !self.received.swap(true, Ordering::SeqCst) {
57
            // Success! Return delivery time as the message.
58
2.50k
            Ok(self.delivery_time)
59
        } else {
60
            // The message was already received.
61
0
            Err(TryRecvError::Empty)
62
        }
63
2.50k
    }
64
65
    /// Receives a message from the channel.
66
    #[inline]
67
4
    pub(crate) fn recv(&self, deadline: Option<Instant>) -> Result<Instant, RecvTimeoutError> {
68
        // We use relaxed ordering because this is just an optional optimistic check.
69
4
        if self.received.load(Ordering::Relaxed) {
70
            // The message has already been received.
71
1
            utils::sleep_until(deadline);
72
1
            return Err(RecvTimeoutError::Timeout);
73
3
        }
74
75
        // Wait until the message is received or the deadline is reached.
76
        loop {
77
6
            let now = Instant::now();
78
79
3
            let deadline = match 
deadline2
{
80
                // Check if we can receive the next message.
81
6
                _ if now >= self.delivery_tim
e => break2
,
82
                // Check if the timeout deadline has been reached.
83
3
                Some(
d1
) if now >=
d => return Err(RecvTimeoutError::Timeout)1
,
84
85
                // Sleep until one of the above happens
86
2
                Some(
d1
) if d < self.delivery_tim
e => d1
,
87
2
                _ => self.delivery_time,
88
            };
89
90
3
            thread::sleep(deadline - now);
91
        }
92
93
        // Try receiving the message if it is still available.
94
2
        if !self.received.swap(true, Ordering::SeqCst) {
95
            // Success! Return the message, which is the instant at which it was delivered.
96
2
            Ok(self.delivery_time)
97
        } else {
98
            // The message was already received. Block forever.
99
0
            utils::sleep_until(None);
100
0
            unreachable!()
101
        }
102
4
    }
Unexecuted instantiation: <crossbeam_channel::flavors::at::Channel>::recv
Unexecuted instantiation: <crossbeam_channel::flavors::at::Channel>::recv
Unexecuted instantiation: <crossbeam_channel::flavors::at::Channel>::recv
<crossbeam_channel::flavors::at::Channel>::recv
Line
Count
Source
67
4
    pub(crate) fn recv(&self, deadline: Option<Instant>) -> Result<Instant, RecvTimeoutError> {
68
        // We use relaxed ordering because this is just an optional optimistic check.
69
4
        if self.received.load(Ordering::Relaxed) {
70
            // The message has already been received.
71
1
            utils::sleep_until(deadline);
72
1
            return Err(RecvTimeoutError::Timeout);
73
3
        }
74
75
        // Wait until the message is received or the deadline is reached.
76
        loop {
77
6
            let now = Instant::now();
78
79
3
            let deadline = match 
deadline2
{
80
                // Check if we can receive the next message.
81
6
                _ if now >= self.delivery_tim
e => break2
,
82
                // Check if the timeout deadline has been reached.
83
3
                Some(
d1
) if now >=
d => return Err(RecvTimeoutError::Timeout)1
,
84
85
                // Sleep until one of the above happens
86
2
                Some(
d1
) if d < self.delivery_tim
e => d1
,
87
2
                _ => self.delivery_time,
88
            };
89
90
3
            thread::sleep(deadline - now);
91
        }
92
93
        // Try receiving the message if it is still available.
94
2
        if !self.received.swap(true, Ordering::SeqCst) {
95
            // Success! Return the message, which is the instant at which it was delivered.
96
2
            Ok(self.delivery_time)
97
        } else {
98
            // The message was already received. Block forever.
99
0
            utils::sleep_until(None);
100
0
            unreachable!()
101
        }
102
4
    }
Unexecuted instantiation: <crossbeam_channel::flavors::at::Channel>::recv
Unexecuted instantiation: <crossbeam_channel::flavors::at::Channel>::recv
Unexecuted instantiation: <crossbeam_channel::flavors::at::Channel>::recv
Unexecuted instantiation: <crossbeam_channel::flavors::at::Channel>::recv
Unexecuted instantiation: <crossbeam_channel::flavors::at::Channel>::recv
Unexecuted instantiation: <crossbeam_channel::flavors::at::Channel>::recv
Unexecuted instantiation: <crossbeam_channel::flavors::at::Channel>::recv
Unexecuted instantiation: <crossbeam_channel::flavors::at::Channel>::recv
Unexecuted instantiation: <crossbeam_channel::flavors::at::Channel>::recv
103
104
    /// Reads a message from the channel.
105
    #[inline]
106
9.86k
    pub(crate) unsafe fn read(&self, token: &mut Token) -> Result<Instant, ()> {
107
9.86k
        token.at.ok_or(())
108
9.86k
    }
<crossbeam_channel::flavors::at::Channel>::read
Line
Count
Source
106
2.50k
    pub(crate) unsafe fn read(&self, token: &mut Token) -> Result<Instant, ()> {
107
2.50k
        token.at.ok_or(())
108
2.50k
    }
<crossbeam_channel::flavors::at::Channel>::read
Line
Count
Source
106
4.85k
    pub(crate) unsafe fn read(&self, token: &mut Token) -> Result<Instant, ()> {
107
4.85k
        token.at.ok_or(())
108
4.85k
    }
<crossbeam_channel::flavors::at::Channel>::read
Line
Count
Source
106
3
    pub(crate) unsafe fn read(&self, token: &mut Token) -> Result<Instant, ()> {
107
3
        token.at.ok_or(())
108
3
    }
<crossbeam_channel::flavors::at::Channel>::read
Line
Count
Source
106
2.50k
    pub(crate) unsafe fn read(&self, token: &mut Token) -> Result<Instant, ()> {
107
2.50k
        token.at.ok_or(())
108
2.50k
    }
109
110
    /// Returns `true` if the channel is empty.
111
    #[inline]
112
58.4k
    pub(crate) fn is_empty(&self) -> bool {
113
58.4k
        // We use relaxed ordering because this is just an optional optimistic check.
114
58.4k
        if self.received.load(Ordering::Relaxed) {
115
46.6k
            return true;
116
11.7k
        }
117
11.7k
118
11.7k
        // If the delivery time hasn't been reached yet, the channel is empty.
119
11.7k
        if Instant::now() < self.delivery_time {
120
7.64k
            return true;
121
3.52k
        }
122
3.52k
123
3.52k
        // The delivery time has been reached. The channel is empty only if the message has already
124
3.52k
        // been received.
125
3.52k
        self.received.load(Ordering::SeqCst)
126
57.7k
    }
Unexecuted instantiation: <crossbeam_channel::flavors::at::Channel>::is_empty
Unexecuted instantiation: <crossbeam_channel::flavors::at::Channel>::is_empty
Unexecuted instantiation: <crossbeam_channel::flavors::at::Channel>::is_empty
<crossbeam_channel::flavors::at::Channel>::is_empty
Line
Count
Source
112
55.4k
    pub(crate) fn is_empty(&self) -> bool {
113
55.4k
        // We use relaxed ordering because this is just an optional optimistic check.
114
55.4k
        if self.received.load(Ordering::Relaxed) {
115
46.6k
            return true;
116
8.79k
        }
117
8.79k
118
8.79k
        // If the delivery time hasn't been reached yet, the channel is empty.
119
8.79k
        if Instant::now() < self.delivery_time {
120
7.13k
            return true;
121
1.01k
        }
122
1.01k
123
1.01k
        // The delivery time has been reached. The channel is empty only if the message has already
124
1.01k
        // been received.
125
1.01k
        self.received.load(Ordering::SeqCst)
126
54.7k
    }
Unexecuted instantiation: <crossbeam_channel::flavors::at::Channel>::is_empty
Unexecuted instantiation: <crossbeam_channel::flavors::at::Channel>::is_empty
<crossbeam_channel::flavors::at::Channel>::is_empty
Line
Count
Source
112
498
    pub(crate) fn is_empty(&self) -> bool {
113
498
        // We use relaxed ordering because this is just an optional optimistic check.
114
498
        if self.received.load(Ordering::Relaxed) {
115
0
            return true;
116
498
        }
117
498
118
498
        // If the delivery time hasn't been reached yet, the channel is empty.
119
498
        if Instant::now() < self.delivery_time {
120
504
            return true;
121
4
        }
122
4
123
4
        // The delivery time has been reached. The channel is empty only if the message has already
124
4
        // been received.
125
4
        self.received.load(Ordering::SeqCst)
126
508
    }
Unexecuted instantiation: <crossbeam_channel::flavors::at::Channel>::is_empty
Unexecuted instantiation: <crossbeam_channel::flavors::at::Channel>::is_empty
Unexecuted instantiation: <crossbeam_channel::flavors::at::Channel>::is_empty
Unexecuted instantiation: <crossbeam_channel::flavors::at::Channel>::is_empty
<crossbeam_channel::flavors::at::Channel>::is_empty
Line
Count
Source
112
2.50k
    pub(crate) fn is_empty(&self) -> bool {
113
2.50k
        // We use relaxed ordering because this is just an optional optimistic check.
114
2.50k
        if self.received.load(Ordering::Relaxed) {
115
0
            return true;
116
2.50k
        }
117
2.50k
118
2.50k
        // If the delivery time hasn't been reached yet, the channel is empty.
119
2.50k
        if Instant::now() < self.delivery_time {
120
0
            return true;
121
2.50k
        }
122
2.50k
123
2.50k
        // The delivery time has been reached. The channel is empty only if the message has already
124
2.50k
        // been received.
125
2.50k
        self.received.load(Ordering::SeqCst)
126
2.50k
    }
127
128
    /// Returns `true` if the channel is full.
129
    #[inline]
130
3
    pub(crate) fn is_full(&self) -> bool {
131
3
        !self.is_empty()
132
3
    }
133
134
    /// Returns the number of messages in the channel.
135
    #[inline]
136
3
    pub(crate) fn len(&self) -> usize {
137
3
        if self.is_empty() {
138
2
            0
139
        } else {
140
1
            1
141
        }
142
3
    }
Unexecuted instantiation: <crossbeam_channel::flavors::at::Channel>::len
<crossbeam_channel::flavors::at::Channel>::len
Line
Count
Source
136
3
    pub(crate) fn len(&self) -> usize {
137
3
        if self.is_empty() {
138
2
            0
139
        } else {
140
1
            1
141
        }
142
3
    }
Unexecuted instantiation: <crossbeam_channel::flavors::at::Channel>::len
Unexecuted instantiation: <crossbeam_channel::flavors::at::Channel>::len
Unexecuted instantiation: <crossbeam_channel::flavors::at::Channel>::len
Unexecuted instantiation: <crossbeam_channel::flavors::at::Channel>::len
143
144
    /// Returns the capacity of the channel.
145
    #[inline]
146
10
    pub(crate) fn capacity(&self) -> Option<usize> {
147
10
        Some(1)
148
10
    }
149
}
150
151
impl SelectHandle for Channel {
152
    #[inline]
153
32.9k
    fn try_select(&self, token: &mut Token) -> bool {
154
32.9k
        match self.try_recv() {
155
9.71k
            Ok(msg) => {
156
9.71k
                token.at = Some(msg);
157
9.71k
                true
158
            }
159
23.2k
            Err(TryRecvError::Disconnected) => {
160
0
                token.at = None;
161
0
                true
162
            }
163
23.2k
            Err(TryRecvError::Empty) => false,
164
        }
165
32.9k
    }
Unexecuted instantiation: <crossbeam_channel::flavors::at::Channel as crossbeam_channel::select::SelectHandle>::try_select
<crossbeam_channel::flavors::at::Channel as crossbeam_channel::select::SelectHandle>::try_select
Line
Count
Source
153
2.50k
    fn try_select(&self, token: &mut Token) -> bool {
154
2.50k
        match self.try_recv() {
155
2.50k
            Ok(msg) => {
156
2.50k
                token.at = Some(msg);
157
2.50k
                true
158
            }
159
0
            Err(TryRecvError::Disconnected) => {
160
0
                token.at = None;
161
0
                true
162
            }
163
0
            Err(TryRecvError::Empty) => false,
164
        }
165
2.50k
    }
Unexecuted instantiation: <crossbeam_channel::flavors::at::Channel as crossbeam_channel::select::SelectHandle>::try_select
<crossbeam_channel::flavors::at::Channel as crossbeam_channel::select::SelectHandle>::try_select
Line
Count
Source
153
27.8k
    fn try_select(&self, token: &mut Token) -> bool {
154
27.8k
        match self.try_recv() {
155
4.70k
            Ok(msg) => {
156
4.70k
                token.at = Some(msg);
157
4.70k
                true
158
            }
159
23.1k
            Err(TryRecvError::Disconnected) => {
160
0
                token.at = None;
161
0
                true
162
            }
163
23.2k
            Err(TryRecvError::Empty) => false,
164
        }
165
27.9k
    }
Unexecuted instantiation: <crossbeam_channel::flavors::at::Channel as crossbeam_channel::select::SelectHandle>::try_select
<crossbeam_channel::flavors::at::Channel as crossbeam_channel::select::SelectHandle>::try_select
Line
Count
Source
153
41
    fn try_select(&self, token: &mut Token) -> bool {
154
41
        match self.try_recv() {
155
4
            Ok(msg) => {
156
4
                token.at = Some(msg);
157
4
                true
158
            }
159
37
            Err(TryRecvError::Disconnected) => {
160
0
                token.at = None;
161
0
                true
162
            }
163
37
            Err(TryRecvError::Empty) => false,
164
        }
165
41
    }
Unexecuted instantiation: <crossbeam_channel::flavors::at::Channel as crossbeam_channel::select::SelectHandle>::try_select
Unexecuted instantiation: <crossbeam_channel::flavors::at::Channel as crossbeam_channel::select::SelectHandle>::try_select
Unexecuted instantiation: <crossbeam_channel::flavors::at::Channel as crossbeam_channel::select::SelectHandle>::try_select
<crossbeam_channel::flavors::at::Channel as crossbeam_channel::select::SelectHandle>::try_select
Line
Count
Source
153
2.50k
    fn try_select(&self, token: &mut Token) -> bool {
154
2.50k
        match self.try_recv() {
155
2.50k
            Ok(msg) => {
156
2.50k
                token.at = Some(msg);
157
2.50k
                true
158
            }
159
0
            Err(TryRecvError::Disconnected) => {
160
0
                token.at = None;
161
0
                true
162
            }
163
0
            Err(TryRecvError::Empty) => false,
164
        }
165
2.50k
    }
Unexecuted instantiation: <crossbeam_channel::flavors::at::Channel as crossbeam_channel::select::SelectHandle>::try_select
166
167
    #[inline]
168
14.5k
    fn deadline(&self) -> Option<Instant> {
169
14.5k
        // We use relaxed ordering because this is just an optional optimistic check.
170
14.5k
        if self.received.load(Ordering::Relaxed) {
171
7.60k
            None
172
        } else {
173
6.97k
            Some(self.delivery_time)
174
        }
175
14.5k
    }
Unexecuted instantiation: <crossbeam_channel::flavors::at::Channel as crossbeam_channel::select::SelectHandle>::deadline
Unexecuted instantiation: <crossbeam_channel::flavors::at::Channel as crossbeam_channel::select::SelectHandle>::deadline
Unexecuted instantiation: <crossbeam_channel::flavors::at::Channel as crossbeam_channel::select::SelectHandle>::deadline
<crossbeam_channel::flavors::at::Channel as crossbeam_channel::select::SelectHandle>::deadline
Line
Count
Source
168
14.5k
    fn deadline(&self) -> Option<Instant> {
169
14.5k
        // We use relaxed ordering because this is just an optional optimistic check.
170
14.5k
        if self.received.load(Ordering::Relaxed) {
171
7.60k
            None
172
        } else {
173
6.90k
            Some(self.delivery_time)
174
        }
175
14.5k
    }
Unexecuted instantiation: <crossbeam_channel::flavors::at::Channel as crossbeam_channel::select::SelectHandle>::deadline
<crossbeam_channel::flavors::at::Channel as crossbeam_channel::select::SelectHandle>::deadline
Line
Count
Source
168
71
    fn deadline(&self) -> Option<Instant> {
169
71
        // We use relaxed ordering because this is just an optional optimistic check.
170
71
        if self.received.load(Ordering::Relaxed) {
171
0
            None
172
        } else {
173
71
            Some(self.delivery_time)
174
        }
175
71
    }
Unexecuted instantiation: <crossbeam_channel::flavors::at::Channel as crossbeam_channel::select::SelectHandle>::deadline
Unexecuted instantiation: <crossbeam_channel::flavors::at::Channel as crossbeam_channel::select::SelectHandle>::deadline
Unexecuted instantiation: <crossbeam_channel::flavors::at::Channel as crossbeam_channel::select::SelectHandle>::deadline
Unexecuted instantiation: <crossbeam_channel::flavors::at::Channel as crossbeam_channel::select::SelectHandle>::deadline
Unexecuted instantiation: <crossbeam_channel::flavors::at::Channel as crossbeam_channel::select::SelectHandle>::deadline
176
177
    #[inline]
178
10.3k
    fn register(&self, _oper: Operation, _cx: &Context) -> bool {
179
10.3k
        self.is_ready()
180
10.3k
    }
<crossbeam_channel::flavors::at::Channel as crossbeam_channel::select::SelectHandle>::register
Line
Count
Source
178
10.3k
    fn register(&self, _oper: Operation, _cx: &Context) -> bool {
179
10.3k
        self.is_ready()
180
10.3k
    }
<crossbeam_channel::flavors::at::Channel as crossbeam_channel::select::SelectHandle>::register
Line
Count
Source
178
35
    fn register(&self, _oper: Operation, _cx: &Context) -> bool {
179
35
        self.is_ready()
180
35
    }
181
182
    #[inline]
183
9.28k
    fn unregister(&self, _oper: Operation) {}
<crossbeam_channel::flavors::at::Channel as crossbeam_channel::select::SelectHandle>::unregister
Line
Count
Source
183
9.25k
    fn unregister(&self, _oper: Operation) {}
<crossbeam_channel::flavors::at::Channel as crossbeam_channel::select::SelectHandle>::unregister
Line
Count
Source
183
34
    fn unregister(&self, _oper: Operation) {}
184
185
    #[inline]
186
    fn accept(&self, token: &mut Token, _cx: &Context) -> bool {
187
        self.try_select(token)
188
    }
189
190
    #[inline]
191
61.5k
    fn is_ready(&self) -> bool {
192
61.5k
        !self.is_empty()
193
61.5k
    }
<crossbeam_channel::flavors::at::Channel as crossbeam_channel::select::SelectHandle>::is_ready
Line
Count
Source
191
58.5k
    fn is_ready(&self) -> bool {
192
58.5k
        !self.is_empty()
193
58.5k
    }
<crossbeam_channel::flavors::at::Channel as crossbeam_channel::select::SelectHandle>::is_ready
Line
Count
Source
191
500
    fn is_ready(&self) -> bool {
192
500
        !self.is_empty()
193
500
    }
<crossbeam_channel::flavors::at::Channel as crossbeam_channel::select::SelectHandle>::is_ready
Line
Count
Source
191
2.50k
    fn is_ready(&self) -> bool {
192
2.50k
        !self.is_empty()
193
2.50k
    }
194
195
    #[inline]
196
3.56k
    fn watch(&self, _oper: Operation, _cx: &Context) -> bool {
197
3.56k
        self.is_ready()
198
3.56k
    }
<crossbeam_channel::flavors::at::Channel as crossbeam_channel::select::SelectHandle>::watch
Line
Count
Source
196
3.53k
    fn watch(&self, _oper: Operation, _cx: &Context) -> bool {
197
3.53k
        self.is_ready()
198
3.53k
    }
<crossbeam_channel::flavors::at::Channel as crossbeam_channel::select::SelectHandle>::watch
Line
Count
Source
196
36
    fn watch(&self, _oper: Operation, _cx: &Context) -> bool {
197
36
        self.is_ready()
198
36
    }
199
200
    #[inline]
201
3.28k
    fn unwatch(&self, _oper: Operation) {}
<crossbeam_channel::flavors::at::Channel as crossbeam_channel::select::SelectHandle>::unwatch
Line
Count
Source
201
3.24k
    fn unwatch(&self, _oper: Operation) {}
<crossbeam_channel::flavors::at::Channel as crossbeam_channel::select::SelectHandle>::unwatch
Line
Count
Source
201
34
    fn unwatch(&self, _oper: Operation) {}
202
}