Skip to content

Commit 721382b

Browse files
bors[bot]glorvtaiki-epoliorceticsc410-f3r
authored
Merge #964
964: v0.8: Prepare for the next release r=taiki-e a=taiki-e Changes: - crossbeam-channel 0.5.6 -> 0.5.7 - Improve handling of very large timeout. (#953) - crossbeam-deque 0.8.2 -> 0.8.3 - Add `Stealer::{steal_batch_with_limit, steal_batch_with_limit_and_pop}` methods. (#903) - Add `Injector::{steal_batch_with_limit, steal_batch_with_limit_and_pop}` methods. (#903) - crossbeam-epoch 0.9.13 -> 0.9.14 - Update `memoffset` to 0.8. (#955) - crossbeam-utils 0.8.14 -> 0.8.15 - Add `#[clippy::has_significant_drop]` to `ShardedLock{Read,Write}Guard`. (#958) - Improve handling of very large timeout. (#953) - Soft-deprecate `thread::scope()` in favor of the more efficient `std::thread::scope` that stabilized on Rust 1.63. (#954) Backports: - #903 - #936 - #953 - #954 - #955 - #958 Co-authored-by: glorv <[email protected]> Co-authored-by: Taiki Endo <[email protected]> Co-authored-by: Alexis (Poliorcetics) Bourget <[email protected]> Co-authored-by: Caio <[email protected]>
2 parents 366276a + 3f4e797 commit 721382b

File tree

21 files changed

+258
-59
lines changed

21 files changed

+258
-59
lines changed

.github/workflows/ci.yml

+21-14
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ jobs:
5858
runs-on: ${{ matrix.os }}
5959
steps:
6060
- uses: actions/checkout@v3
61-
- uses: dtolnay/rust-toolchain@v1
62-
with:
63-
toolchain: ${{ matrix.rust }}
61+
- name: Install Rust
62+
# --no-self-update is necessary because the windows environment cannot self-update rustup.exe.
63+
run: rustup update ${{ matrix.rust }} --no-self-update && rustup default ${{ matrix.rust }}
6464
- name: Install cross
6565
uses: taiki-e/install-action@cross
6666
if: matrix.target != ''
@@ -80,9 +80,8 @@ jobs:
8080
runs-on: ubuntu-latest
8181
steps:
8282
- uses: actions/checkout@v3
83-
- uses: dtolnay/rust-toolchain@v1
84-
with:
85-
toolchain: ${{ matrix.rust }}
83+
- name: Install Rust
84+
run: rustup update ${{ matrix.rust }} && rustup default ${{ matrix.rust }}
8685
- name: Install cargo-hack
8786
uses: taiki-e/install-action@cargo-hack
8887
- name: Check features
@@ -93,7 +92,8 @@ jobs:
9392
runs-on: ubuntu-latest
9493
steps:
9594
- uses: actions/checkout@v3
96-
- uses: dtolnay/rust-toolchain@nightly
95+
- name: Install Rust
96+
run: rustup update nightly && rustup default nightly
9797
- name: Install cargo-hack
9898
uses: taiki-e/install-action@cargo-hack
9999
- name: Install cargo-minimal-versions
@@ -109,7 +109,8 @@ jobs:
109109
pull-requests: write
110110
steps:
111111
- uses: actions/checkout@v3
112-
- uses: dtolnay/rust-toolchain@nightly
112+
- name: Install Rust
113+
run: rustup update nightly && rustup default nightly
113114
- run: ci/no_atomic.sh
114115
- run: git add -N . && git diff --exit-code
115116
if: github.repository_owner != 'crossbeam-rs' || github.event_name != 'schedule'
@@ -141,7 +142,8 @@ jobs:
141142
runs-on: ubuntu-latest
142143
steps:
143144
- uses: actions/checkout@v3
144-
- uses: dtolnay/rust-toolchain@stable
145+
- name: Install Rust
146+
run: rustup update stable
145147
- name: rustfmt
146148
run: ./ci/rustfmt.sh
147149

@@ -152,7 +154,8 @@ jobs:
152154
# runs-on: ubuntu-latest
153155
# steps:
154156
# - uses: actions/checkout@v3
155-
# - uses: dtolnay/rust-toolchain@stable
157+
# - name: Install Rust
158+
# run: rustup update stable
156159
# - name: clippy
157160
# run: ./ci/clippy.sh
158161

@@ -161,7 +164,8 @@ jobs:
161164
runs-on: ubuntu-latest
162165
steps:
163166
- uses: actions/checkout@v3
164-
- uses: dtolnay/rust-toolchain@miri
167+
- name: Install Rust
168+
run: rustup toolchain install nightly --component miri && rustup default nightly
165169
- name: miri
166170
run: ./ci/miri.sh
167171

@@ -170,7 +174,8 @@ jobs:
170174
runs-on: ubuntu-latest
171175
steps:
172176
- uses: actions/checkout@v3
173-
- uses: dtolnay/rust-toolchain@nightly
177+
- name: Install Rust
178+
run: rustup update nightly && rustup default nightly
174179
- name: Run sanitizers
175180
run: ./ci/san.sh
176181

@@ -179,7 +184,8 @@ jobs:
179184
runs-on: ubuntu-latest
180185
steps:
181186
- uses: actions/checkout@v3
182-
- uses: dtolnay/rust-toolchain@stable
187+
- name: Install Rust
188+
run: rustup update stable
183189
- name: loom
184190
run: ./ci/crossbeam-epoch-loom.sh
185191

@@ -188,7 +194,8 @@ jobs:
188194
runs-on: ubuntu-latest
189195
steps:
190196
- uses: actions/checkout@v3
191-
- uses: dtolnay/rust-toolchain@nightly
197+
- name: Install Rust
198+
run: rustup update nightly && rustup default nightly
192199
- name: docs
193200
run: ./ci/docs.sh
194201

ci/no_atomic.sh

+5
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ for target in $(rustc --print target-list); do
1818
res=$(jq <<<"${target_spec}" -r 'select(."atomic-cas" == false)')
1919
[[ -z "${res}" ]] || no_atomic_cas+=("${target}")
2020
max_atomic_width=$(jq <<<"${target_spec}" -r '."max-atomic-width"')
21+
min_atomic_width=$(jq <<<"${target_spec}" -r '."min-atomic-width"')
2122
case "${max_atomic_width}" in
2223
# It is not clear exactly what `"max-atomic-width" == null` means, but they
2324
# actually seem to have the same max-atomic-width as the target-pointer-width.
@@ -35,6 +36,10 @@ for target in $(rustc --print target-list); do
3536
# There is no `"max-atomic-width" == 16` or `"max-atomic-width" == 8` targets.
3637
*) exit 1 ;;
3738
esac
39+
case "${min_atomic_width}" in
40+
8 | null) ;;
41+
*) no_atomic+=("${target}") ;;
42+
esac
3843
done
3944

4045
cat >"${file}" <<EOF

crossbeam-channel/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# Version 0.5.7
2+
3+
- Improve handling of very large timeout. (#953)
4+
15
# Version 0.5.6
26

37
- Bump the minimum supported Rust version to 1.38. (#877)

crossbeam-channel/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ name = "crossbeam-channel"
44
# - Update CHANGELOG.md
55
# - Update README.md
66
# - Create "crossbeam-channel-X.Y.Z" git tag
7-
version = "0.5.6"
7+
version = "0.5.7"
88
edition = "2018"
99
rust-version = "1.38"
1010
license = "MIT OR Apache-2.0"

crossbeam-channel/src/channel.rs

+21-7
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ use crate::err::{
1414
};
1515
use crate::flavors;
1616
use crate::select::{Operation, SelectHandle, Token};
17-
use crate::utils;
1817

1918
/// Creates a channel of unbounded capacity.
2019
///
@@ -172,8 +171,11 @@ pub fn bounded<T>(cap: usize) -> (Sender<T>, Receiver<T>) {
172171
/// assert!(eq(Instant::now(), start + ms(500)));
173172
/// ```
174173
pub fn after(duration: Duration) -> Receiver<Instant> {
175-
Receiver {
176-
flavor: ReceiverFlavor::At(Arc::new(flavors::at::Channel::new_timeout(duration))),
174+
match Instant::now().checked_add(duration) {
175+
Some(deadline) => Receiver {
176+
flavor: ReceiverFlavor::At(Arc::new(flavors::at::Channel::new_deadline(deadline))),
177+
},
178+
None => never(),
177179
}
178180
}
179181

@@ -320,8 +322,14 @@ pub fn never<T>() -> Receiver<T> {
320322
/// assert!(eq(Instant::now(), start + ms(700)));
321323
/// ```
322324
pub fn tick(duration: Duration) -> Receiver<Instant> {
323-
Receiver {
324-
flavor: ReceiverFlavor::Tick(Arc::new(flavors::tick::Channel::new(duration))),
325+
match Instant::now().checked_add(duration) {
326+
Some(delivery_time) => Receiver {
327+
flavor: ReceiverFlavor::Tick(Arc::new(flavors::tick::Channel::new(
328+
delivery_time,
329+
duration,
330+
))),
331+
},
332+
None => never(),
325333
}
326334
}
327335

@@ -474,7 +482,10 @@ impl<T> Sender<T> {
474482
/// );
475483
/// ```
476484
pub fn send_timeout(&self, msg: T, timeout: Duration) -> Result<(), SendTimeoutError<T>> {
477-
self.send_deadline(msg, utils::convert_timeout_to_deadline(timeout))
485+
match Instant::now().checked_add(timeout) {
486+
Some(deadline) => self.send_deadline(msg, deadline),
487+
None => self.send(msg).map_err(SendTimeoutError::from),
488+
}
478489
}
479490

480491
/// Waits for a message to be sent into the channel, but only until a given deadline.
@@ -864,7 +875,10 @@ impl<T> Receiver<T> {
864875
/// );
865876
/// ```
866877
pub fn recv_timeout(&self, timeout: Duration) -> Result<T, RecvTimeoutError> {
867-
self.recv_deadline(utils::convert_timeout_to_deadline(timeout))
878+
match Instant::now().checked_add(timeout) {
879+
Some(deadline) => self.recv_deadline(deadline),
880+
None => self.recv().map_err(RecvTimeoutError::from),
881+
}
868882
}
869883

870884
/// Waits for a message to be received from the channel, but only before a given deadline.

crossbeam-channel/src/flavors/at.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
55
use std::sync::atomic::{AtomicBool, Ordering};
66
use std::thread;
7-
use std::time::{Duration, Instant};
7+
use std::time::Instant;
88

99
use crate::context::Context;
1010
use crate::err::{RecvTimeoutError, TryRecvError};
@@ -32,11 +32,6 @@ impl Channel {
3232
received: AtomicBool::new(false),
3333
}
3434
}
35-
/// Creates a channel that delivers a message after a certain duration of time.
36-
#[inline]
37-
pub(crate) fn new_timeout(dur: Duration) -> Self {
38-
Self::new_deadline(utils::convert_timeout_to_deadline(dur))
39-
}
4035

4136
/// Attempts to receive a message without blocking.
4237
#[inline]

crossbeam-channel/src/flavors/tick.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ use crossbeam_utils::atomic::AtomicCell;
1010
use crate::context::Context;
1111
use crate::err::{RecvTimeoutError, TryRecvError};
1212
use crate::select::{Operation, SelectHandle, Token};
13-
use crate::utils;
1413

1514
/// Result of a receive operation.
1615
pub(crate) type TickToken = Option<Instant>;
@@ -27,9 +26,9 @@ pub(crate) struct Channel {
2726
impl Channel {
2827
/// Creates a channel that delivers messages periodically.
2928
#[inline]
30-
pub(crate) fn new(dur: Duration) -> Self {
29+
pub(crate) fn new(delivery_time: Instant, dur: Duration) -> Self {
3130
Channel {
32-
delivery_time: AtomicCell::new(utils::convert_timeout_to_deadline(dur)),
31+
delivery_time: AtomicCell::new(delivery_time),
3332
duration: dur,
3433
}
3534
}

crossbeam-channel/src/select.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,10 @@ pub fn select_timeout<'a>(
487487
handles: &mut [(&'a dyn SelectHandle, usize, *const u8)],
488488
timeout: Duration,
489489
) -> Result<SelectedOperation<'a>, SelectTimeoutError> {
490-
select_deadline(handles, utils::convert_timeout_to_deadline(timeout))
490+
match Instant::now().checked_add(timeout) {
491+
Some(deadline) => select_deadline(handles, deadline),
492+
None => Ok(select(handles)),
493+
}
491494
}
492495

493496
/// Blocks until a given deadline, or until one of the operations becomes ready and selects it.
@@ -1045,7 +1048,10 @@ impl<'a> Select<'a> {
10451048
/// }
10461049
/// ```
10471050
pub fn ready_timeout(&mut self, timeout: Duration) -> Result<usize, ReadyTimeoutError> {
1048-
self.ready_deadline(utils::convert_timeout_to_deadline(timeout))
1051+
match Instant::now().checked_add(timeout) {
1052+
Some(deadline) => self.ready_deadline(deadline),
1053+
None => Ok(self.ready()),
1054+
}
10491055
}
10501056

10511057
/// Blocks until a given deadline, or until one of the operations becomes ready.

crossbeam-channel/src/utils.rs

-8
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,3 @@ pub(crate) fn sleep_until(deadline: Option<Instant>) {
5656
}
5757
}
5858
}
59-
60-
// https://github.com/crossbeam-rs/crossbeam/issues/795
61-
pub(crate) fn convert_timeout_to_deadline(timeout: Duration) -> Instant {
62-
match Instant::now().checked_add(timeout) {
63-
Some(deadline) => deadline,
64-
None => Instant::now() + Duration::from_secs(86400 * 365 * 30),
65-
}
66-
}

crossbeam-deque/CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# Version 0.8.3
2+
3+
- Add `Stealer::{steal_batch_with_limit, steal_batch_with_limit_and_pop}` methods. (#903)
4+
- Add `Injector::{steal_batch_with_limit, steal_batch_with_limit_and_pop}` methods. (#903)
5+
16
# Version 0.8.2
27

38
- Bump the minimum supported Rust version to 1.38. (#877)

crossbeam-deque/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ name = "crossbeam-deque"
44
# - Update CHANGELOG.md
55
# - Update README.md
66
# - Create "crossbeam-deque-X.Y.Z" git tag
7-
version = "0.8.2"
7+
version = "0.8.3"
88
edition = "2018"
99
rust-version = "1.38"
1010
license = "MIT OR Apache-2.0"

0 commit comments

Comments
 (0)