Skip to content

Commit 1670e3c

Browse files
committed
---
yaml --- r: 64863 b: refs/heads/snap-stage3 c: 3f6b4c2 h: refs/heads/master i: 64861: a57a799 64859: ef5ac4b 64855: eabe26a 64847: a961d8c 64831: 6f2e4d6 v: v3
1 parent f578226 commit 1670e3c

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: cccfa8acc450631fe9520abbe40360927ce1961d
4+
refs/heads/snap-stage3: 3f6b4c24ec2234a06632234eaf3014ae0e4adc66
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/libstd/rt/comm.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,25 @@ impl<T> PortOne<T> {
180180
}
181181

182182
impl<T> Select for PortOne<T> {
183-
#[inline]
183+
#[inline] #[cfg(not(test))]
184184
fn optimistic_check(&mut self) -> bool {
185185
unsafe { (*self.packet()).state.load(Acquire) == STATE_ONE }
186186
}
187187

188+
#[inline] #[cfg(test)]
189+
fn optimistic_check(&mut self) -> bool {
190+
// The optimistic check is never necessary for correctness. For testing
191+
// purposes, making it randomly return false simulates a racing sender.
192+
use rand::{Rand, rng};
193+
let mut rng = rng();
194+
let actually_check = Rand::rand(&mut rng);
195+
if actually_check {
196+
unsafe { (*self.packet()).state.load(Acquire) == STATE_ONE }
197+
} else {
198+
false
199+
}
200+
}
201+
188202
fn block_on(&mut self, sched: &mut Scheduler, task: BlockedTask) -> bool {
189203
unsafe {
190204
// Atomically swap the task pointer into the Packet state, issuing

0 commit comments

Comments
 (0)