summaryrefslogtreecommitdiffstats
path: root/vendor/crossbeam-channel/src/flavors
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/crossbeam-channel/src/flavors')
-rw-r--r--vendor/crossbeam-channel/src/flavors/at.rs7
-rw-r--r--vendor/crossbeam-channel/src/flavors/list.rs11
-rw-r--r--vendor/crossbeam-channel/src/flavors/tick.rs5
3 files changed, 14 insertions, 9 deletions
diff --git a/vendor/crossbeam-channel/src/flavors/at.rs b/vendor/crossbeam-channel/src/flavors/at.rs
index ca5ee60f5..515c4e33b 100644
--- a/vendor/crossbeam-channel/src/flavors/at.rs
+++ b/vendor/crossbeam-channel/src/flavors/at.rs
@@ -4,7 +4,7 @@
use std::sync::atomic::{AtomicBool, Ordering};
use std::thread;
-use std::time::{Duration, Instant};
+use std::time::Instant;
use crate::context::Context;
use crate::err::{RecvTimeoutError, TryRecvError};
@@ -32,11 +32,6 @@ impl Channel {
received: AtomicBool::new(false),
}
}
- /// Creates a channel that delivers a message after a certain duration of time.
- #[inline]
- pub(crate) fn new_timeout(dur: Duration) -> Self {
- Self::new_deadline(utils::convert_timeout_to_deadline(dur))
- }
/// Attempts to receive a message without blocking.
#[inline]
diff --git a/vendor/crossbeam-channel/src/flavors/list.rs b/vendor/crossbeam-channel/src/flavors/list.rs
index 6090b8d47..230edd8d2 100644
--- a/vendor/crossbeam-channel/src/flavors/list.rs
+++ b/vendor/crossbeam-channel/src/flavors/list.rs
@@ -584,6 +584,17 @@ impl<T> Channel<T> {
let mut head = self.head.index.load(Ordering::Acquire);
let mut block = self.head.block.load(Ordering::Acquire);
+ // If we're going to be dropping messages we need to synchronize with initialization
+ if head >> SHIFT != tail >> SHIFT {
+ // The block can be null here only if a sender is in the process of initializing the
+ // channel while another sender managed to send a message by inserting it into the
+ // semi-initialized channel and advanced the tail.
+ // In that case, just wait until it gets initialized.
+ while block.is_null() {
+ backoff.snooze();
+ block = self.head.block.load(Ordering::Acquire);
+ }
+ }
unsafe {
// Drop all messages between head and tail and deallocate the heap-allocated blocks.
while head >> SHIFT != tail >> SHIFT {
diff --git a/vendor/crossbeam-channel/src/flavors/tick.rs b/vendor/crossbeam-channel/src/flavors/tick.rs
index 4201b6eb0..d38f6a594 100644
--- a/vendor/crossbeam-channel/src/flavors/tick.rs
+++ b/vendor/crossbeam-channel/src/flavors/tick.rs
@@ -10,7 +10,6 @@ use crossbeam_utils::atomic::AtomicCell;
use crate::context::Context;
use crate::err::{RecvTimeoutError, TryRecvError};
use crate::select::{Operation, SelectHandle, Token};
-use crate::utils;
/// Result of a receive operation.
pub(crate) type TickToken = Option<Instant>;
@@ -27,9 +26,9 @@ pub(crate) struct Channel {
impl Channel {
/// Creates a channel that delivers messages periodically.
#[inline]
- pub(crate) fn new(dur: Duration) -> Self {
+ pub(crate) fn new(delivery_time: Instant, dur: Duration) -> Self {
Channel {
- delivery_time: AtomicCell::new(utils::convert_timeout_to_deadline(dur)),
+ delivery_time: AtomicCell::new(delivery_time),
duration: dur,
}
}