Bug 1919921 - Update crossbeam-channel r=supply-chain-reviewers,gfx-reviewers,lsalzman

Differential Revision: https://phabricator.services.mozilla.com/D222884
This commit is contained in:
Glenn Watson
2024-09-22 20:03:44 +00:00
parent d6e66a8680
commit c28a618356
29 changed files with 435 additions and 383 deletions

5
Cargo.lock generated
View File

@@ -1079,11 +1079,10 @@ dependencies = [
[[package]]
name = "crossbeam-channel"
version = "0.5.6"
version = "0.5.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2dd04ddaf88237dc3b8d8f9a3c1004b506b54b3313403944054d23c0870c521"
checksum = "33480d6946193aa8033910124896ca395333cae7e2d1113d1fef6c3272217df2"
dependencies = [
"cfg-if",
"crossbeam-utils",
]

14
gfx/wr/Cargo.lock generated
View File

@@ -581,11 +581,10 @@ checksum = "bd66663db5a988098a89599d4857919b3acf7f61402e61365acfd3919857b9be"
[[package]]
name = "crossbeam-channel"
version = "0.5.0"
version = "0.5.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dca26ee1f8d361640700bde38b2c37d8c22b3ce2d360e1fc1c74ea4b0aa7d775"
checksum = "33480d6946193aa8033910124896ca395333cae7e2d1113d1fef6c3272217df2"
dependencies = [
"cfg-if 1.0.0",
"crossbeam-utils",
]
@@ -616,14 +615,9 @@ dependencies = [
[[package]]
name = "crossbeam-utils"
version = "0.8.1"
version = "0.8.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "02d96d1e189ef58269ebe5b97953da3274d83a93af647c2ddd6f9dab28cedb8d"
dependencies = [
"autocfg",
"cfg-if 1.0.0",
"lazy_static",
]
checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80"
[[package]]
name = "crunchy"

View File

@@ -1191,6 +1191,11 @@ who = "Mike Hommey <mh+mozilla@glandium.org>"
criteria = "safe-to-deploy"
delta = "0.5.4 -> 0.5.6"
[[audits.crossbeam-channel]]
who = "Glenn Watson <git@intuitionlibrary.com>"
criteria = "safe-to-deploy"
delta = "0.5.12 -> 0.5.13"
[[audits.crossbeam-deque]]
who = "Mike Hommey <mh+mozilla@glandium.org>"
criteria = "safe-to-deploy"
@@ -2326,23 +2331,11 @@ who = "Erich Gubler <erichdongubler@gmail.com>"
criteria = "safe-to-deploy"
delta = "0.2.3 -> 0.3.0"
[[audits.gpu-descriptor]]
who = "Erich Gubler <erichdongubler@gmail.com>"
criteria = "safe-to-deploy"
delta = "0.3.0 -> 0.3.0@git:7b71a4e47c81903ad75e2c53deb5ab1310f6ff4d"
importable = false
[[audits.gpu-descriptor-types]]
who = "Erich Gubler <erichdongubler@gmail.com>"
criteria = "safe-to-deploy"
delta = "0.1.1 -> 0.2.0"
[[audits.gpu-descriptor-types]]
who = "Erich Gubler <erichdongubler@gmail.com>"
criteria = "safe-to-deploy"
delta = "0.2.0 -> 0.2.0@git:7b71a4e47c81903ad75e2c53deb5ab1310f6ff4d"
importable = false
[[audits.guid_win]]
who = "Bobby Holley <bobbyholley@gmail.com>"
criteria = "safe-to-deploy"

View File

@@ -319,10 +319,6 @@ criteria = "safe-to-deploy"
version = "0.2.2"
criteria = "safe-to-deploy"
[[exemptions.crc32fast]]
version = "1.3.2"
criteria = "safe-to-deploy"
[[exemptions.crossbeam-channel]]
version = "0.5.4"
criteria = "safe-to-deploy"
@@ -339,10 +335,6 @@ criteria = "safe-to-deploy"
version = "0.8.8"
criteria = "safe-to-deploy"
[[exemptions.d3d12]]
version = "0.4.1"
criteria = "safe-to-deploy"
[[exemptions.darling]]
version = "0.13.4"
criteria = "safe-to-deploy"

View File

@@ -16,13 +16,6 @@ user-id = 189
user-login = "BurntSushi"
user-name = "Andrew Gallant"
[[publisher.anstyle]]
version = "1.0.3"
when = "2023-09-11"
user-id = 6743
user-login = "epage"
user-name = "Ed Page"
[[publisher.anstyle]]
version = "1.0.8"
when = "2024-07-25"
@@ -107,13 +100,6 @@ user-id = 3788
user-login = "emilio"
user-name = "Emilio Cobos Álvarez"
[[publisher.clap]]
version = "4.4.5"
when = "2023-09-25"
user-id = 6743
user-login = "epage"
user-name = "Ed Page"
[[publisher.clap]]
version = "4.5.16"
when = "2024-08-15"
@@ -121,20 +107,6 @@ user-id = 6743
user-login = "epage"
user-name = "Ed Page"
[[publisher.clap_builder]]
version = "4.4.5"
when = "2023-09-25"
user-id = 6743
user-login = "epage"
user-name = "Ed Page"
[[publisher.clap_derive]]
version = "4.4.2"
when = "2023-08-31"
user-id = 6743
user-login = "epage"
user-name = "Ed Page"
[[publisher.clap_derive]]
version = "4.5.13"
when = "2024-07-31"
@@ -142,13 +114,6 @@ user-id = 6743
user-login = "epage"
user-name = "Ed Page"
[[publisher.clap_lex]]
version = "0.5.1"
when = "2023-08-24"
user-id = 6743
user-login = "epage"
user-name = "Ed Page"
[[publisher.clap_lex]]
version = "0.7.2"
when = "2024-07-25"
@@ -261,13 +226,6 @@ user-id = 5946
user-login = "jrmuizel"
user-name = "Jeff Muizelaar"
[[publisher.glean]]
version = "60.5.0"
when = "2024-08-06"
user-id = 48
user-login = "badboy"
user-name = "Jan-Erik Rediger"
[[publisher.glean]]
version = "61.0.0"
when = "2024-08-21"
@@ -275,13 +233,6 @@ user-id = 48
user-login = "badboy"
user-name = "Jan-Erik Rediger"
[[publisher.glean-core]]
version = "60.5.0"
when = "2024-08-06"
user-id = 48
user-login = "badboy"
user-name = "Jan-Erik Rediger"
[[publisher.glean-core]]
version = "61.0.0"
when = "2024-08-21"
@@ -560,27 +511,6 @@ user-id = 2915
user-login = "Amanieu"
user-name = "Amanieu d'Antras"
[[publisher.serde]]
version = "1.0.204"
when = "2024-07-06"
user-id = 3618
user-login = "dtolnay"
user-name = "David Tolnay"
[[publisher.serde]]
version = "1.0.208"
when = "2024-08-15"
user-id = 3618
user-login = "dtolnay"
user-name = "David Tolnay"
[[publisher.serde]]
version = "1.0.209"
when = "2024-08-24"
user-id = 3618
user-login = "dtolnay"
user-name = "David Tolnay"
[[publisher.serde]]
version = "1.0.210"
when = "2024-09-06"
@@ -595,27 +525,6 @@ user-id = 3618
user-login = "dtolnay"
user-name = "David Tolnay"
[[publisher.serde_derive]]
version = "1.0.204"
when = "2024-07-06"
user-id = 3618
user-login = "dtolnay"
user-name = "David Tolnay"
[[publisher.serde_derive]]
version = "1.0.208"
when = "2024-08-15"
user-id = 3618
user-login = "dtolnay"
user-name = "David Tolnay"
[[publisher.serde_derive]]
version = "1.0.209"
when = "2024-08-24"
user-id = 3618
user-login = "dtolnay"
user-name = "David Tolnay"
[[publisher.serde_derive]]
version = "1.0.210"
when = "2024-09-06"
@@ -651,13 +560,6 @@ user-id = 2017
user-login = "mbrubeck"
user-name = "Matt Brubeck"
[[publisher.syn]]
version = "1.0.109"
when = "2023-02-24"
user-id = 3618
user-login = "dtolnay"
user-name = "David Tolnay"
[[publisher.syn]]
version = "2.0.68"
when = "2024-06-23"
@@ -742,108 +644,54 @@ user-id = 1139
user-login = "Manishearth"
user-name = "Manish Goregaokar"
[[publisher.uniffi]]
version = "0.27.3"
when = "2024-06-03"
user-id = 127697
user-login = "bendk"
[[publisher.uniffi]]
version = "0.28.1"
when = "2024-08-13"
user-id = 127697
user-login = "bendk"
[[publisher.uniffi_bindgen]]
version = "0.27.3"
when = "2024-06-03"
user-id = 127697
user-login = "bendk"
[[publisher.uniffi_bindgen]]
version = "0.28.1"
when = "2024-08-13"
user-id = 127697
user-login = "bendk"
[[publisher.uniffi_build]]
version = "0.27.3"
when = "2024-06-03"
user-id = 127697
user-login = "bendk"
[[publisher.uniffi_build]]
version = "0.28.1"
when = "2024-08-13"
user-id = 127697
user-login = "bendk"
[[publisher.uniffi_checksum_derive]]
version = "0.27.3"
when = "2024-06-03"
user-id = 127697
user-login = "bendk"
[[publisher.uniffi_checksum_derive]]
version = "0.28.1"
when = "2024-08-13"
user-id = 127697
user-login = "bendk"
[[publisher.uniffi_core]]
version = "0.27.3"
when = "2024-06-03"
user-id = 127697
user-login = "bendk"
[[publisher.uniffi_core]]
version = "0.28.1"
when = "2024-08-13"
user-id = 127697
user-login = "bendk"
[[publisher.uniffi_macros]]
version = "0.27.3"
when = "2024-06-03"
user-id = 127697
user-login = "bendk"
[[publisher.uniffi_macros]]
version = "0.28.1"
when = "2024-08-13"
user-id = 127697
user-login = "bendk"
[[publisher.uniffi_meta]]
version = "0.27.3"
when = "2024-06-03"
user-id = 127697
user-login = "bendk"
[[publisher.uniffi_meta]]
version = "0.28.1"
when = "2024-08-13"
user-id = 127697
user-login = "bendk"
[[publisher.uniffi_testing]]
version = "0.27.3"
when = "2024-06-03"
user-id = 127697
user-login = "bendk"
[[publisher.uniffi_testing]]
version = "0.28.1"
when = "2024-08-13"
user-id = 127697
user-login = "bendk"
[[publisher.uniffi_udl]]
version = "0.27.3"
when = "2024-06-03"
user-id = 127697
user-login = "bendk"
[[publisher.uniffi_udl]]
version = "0.28.1"
when = "2024-08-13"
@@ -1104,6 +952,17 @@ This is a minor update that looks to add some more detected CPU features and
various other minor portability fixes such as MIRI support.
"""
[[audits.bytecode-alliance.audits.crossbeam-channel]]
who = "Alex Crichton <alex@alexcrichton.com>"
criteria = "safe-to-deploy"
delta = "0.5.4 -> 0.5.8"
notes = """
This diff does what it says on the tin for this version range, notably fixing a
race condition, improving handling of durations, and additionally swapping out a
spin lock with a lock from the standard library. Minor bits of `unsafe` code
are modified but that's expected given the nature of this crate.
"""
[[audits.bytecode-alliance.audits.crypto-common]]
who = "Benjamin Bouvier <public@benj.me>"
criteria = "safe-to-deploy"
@@ -1173,12 +1032,6 @@ who = "Pat Hickey <phickey@fastly.com>"
criteria = "safe-to-deploy"
version = "0.3.27"
[[audits.bytecode-alliance.audits.heck]]
who = "Alex Crichton <alex@alexcrichton.com>"
criteria = "safe-to-deploy"
version = "0.4.0"
notes = "Contains `forbid_unsafe` and only uses `std::fmt` from the standard library. Otherwise only contains string manipulation."
[[audits.bytecode-alliance.audits.heck]]
who = "Alex Crichton <alex@alexcrichton.com>"
criteria = "safe-to-deploy"
@@ -1252,12 +1105,6 @@ criteria = "safe-to-deploy"
delta = "0.31.1 -> 0.32.0"
notes = "Various new features and refactorings as one would expect from an object parsing crate, all looks good."
[[audits.bytecode-alliance.audits.peeking_take_while]]
who = "Nick Fitzgerald <fitzgen@gmail.com>"
criteria = "safe-to-deploy"
version = "1.0.0"
notes = "I am the author of this crate."
[[audits.bytecode-alliance.audits.percent-encoding]]
who = "Alex Crichton <alex@alexcrichton.com>"
criteria = "safe-to-deploy"
@@ -1427,6 +1274,18 @@ and there were no hits.
'''
aggregated-from = "https://chromium.googlesource.com/chromium/src/+/main/third_party/rust/chromium_crates_io/supply-chain/audits.toml?format=TEXT"
[[audits.google.audits.crc32fast]]
who = "Lukasz Anforowicz <lukasza@chromium.org>"
criteria = "safe-to-deploy"
version = "1.4.2"
notes = """
Security review of earlier versions of the crate can be found at
(Google-internal, sorry): go/image-crate-chromium-security-review
Audit comments for 1.4.2 can be found at https://crrev.com/c/4723145.
"""
aggregated-from = "https://chromium.googlesource.com/chromium/src/+/main/third_party/rust/chromium_crates_io/supply-chain/audits.toml?format=TEXT"
[[audits.google.audits.equivalent]]
who = "George Burgess IV <gbiv@google.com>"
criteria = "safe-to-deploy"
@@ -1788,6 +1647,19 @@ version = "0.1.2"
notes = "TOML parser, forked from toml 0.5"
aggregated-from = "https://raw.githubusercontent.com/mozilla/glean/main/supply-chain/audits.toml"
[[audits.mozilla.audits.crossbeam-channel]]
who = "Jan-Erik Rediger <jrediger@mozilla.com>"
criteria = "safe-to-deploy"
delta = "0.5.8 -> 0.5.11"
aggregated-from = "https://raw.githubusercontent.com/mozilla/glean/main/supply-chain/audits.toml"
[[audits.mozilla.audits.crossbeam-channel]]
who = "Jan-Erik Rediger <jrediger@mozilla.com>"
criteria = "safe-to-deploy"
delta = "0.5.11 -> 0.5.12"
notes = "Minimal change fixing a memory leak."
aggregated-from = "https://raw.githubusercontent.com/mozilla/glean/main/supply-chain/audits.toml"
[[audits.mozilla.audits.crossbeam-utils]]
who = "Jan-Erik Rediger <jrediger@mozilla.com>"
criteria = "safe-to-deploy"

View File

@@ -1 +1 @@
{"files":{"CHANGELOG.md":"f87a526ab720644e07509dd76d29c08993a5e52a6d6ec230d809fc31a1c0e403","Cargo.lock":"8af0a5f8b3d1e6f036332a5ecc91b30222343f29a465ea398bca3298c0212f4a","Cargo.toml":"81a227ee6f529cd0cf62327f63eb098fed59c04dde2a8e68aeaa0ea32dbafbcf","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"5734ed989dfca1f625b40281ee9f4530f91b2411ec01cb748223e7eb87e201ab","LICENSE-THIRD-PARTY":"b16db96b93b1d7cf7bea533f572091ec6bca3234fbe0a83038be772ff391a44c","README.md":"4e16587d8f6a15f2016f256535aa6c9429424672ebdcd03c1a7d964746e46127","benches/crossbeam.rs":"96cb1abd23cac3ef8a7174a802e94609926b555bb02c9658c78723d433f1dd92","examples/fibonacci.rs":"4e88fa40048cdc31e9c7bb60347d46f92543d7ddf39cab3b52bfe44affdb6a02","examples/matching.rs":"63c250e164607a7a9f643d46f107bb5da846d49e89cf9069909562d20e530f71","examples/stopwatch.rs":"d02121258f08d56f1eb7997e19bcb9bacb6836cfa0abbba90a9e59d8a50ae5cf","src/channel.rs":"9538e285101c152e23c5ff6a47b0305753d94a5b27f3426499052b0e3d0f97ee","src/context.rs":"ff4d39639ddf16aaab582d4a5f3d10ef2c71afe1abbf4e60f3d9d2ddbd72c230","src/counter.rs":"c49a9f44587888850edeb62f7c8ecd1acecb39c836834254ff3ac934c478440a","src/err.rs":"44cb2024ee6b0cd6fd24996430e53720769f64b4ac35016bc3e05cb9db48681d","src/flavors/array.rs":"508e54587fc8d9e8dfacd16446a601e33838d7bb1dfd9d7ccc3e65315b66b35a","src/flavors/at.rs":"1db64919593b7c14f838c16a22732515f1e716d2d5f6cc639f42631380e545cd","src/flavors/list.rs":"d901d9259185a71aeb5cf74be70e5c38b550c7f38b87e023196cb47fed2d1a11","src/flavors/mod.rs":"3d9d43bc38b0adb18c96c995c2bd3421d8e33ab6c30b20c3c467d21d48e485dc","src/flavors/never.rs":"747da857aa1a7601641f23f4930e6ad00ebaf50456d9be5c7aa270e2ecc24dcb","src/flavors/tick.rs":"69b2dfe0186bc8b9fd7a73e32da59d2656d8150da1e00fba92a412e0907568a3","src/flavors/zero.rs":"7458eb0ece475dc5093b4f2cde13f6de57e4f70291258850de4fa3c951c8f594","src/lib.rs":"3a65706d4124844ffc4c8cb1f8cc779631ec94f449f85cbb68364ad3619404f1","src/select.rs":"3b00c3929d3a8973e46188db41f6ae0b47c89ab108cf7ec2cb348e272e77e132","src/select_macro.rs":"283acd04870356b0c4d3d4046c5070638b562c9ffb8fa29c1a5b90a2509bf3af","src/utils.rs":"0b6e6621198236c077fcb6b66203317e36dc8f1a157dd3b22ad422b6599ae389","src/waker.rs":"6839108d1c9357b3c0c1c162c8b4633ff5ac4f756e95e677ac1293e7df942635","tests/after.rs":"0154a8e152880db17a20514ecdd49dabc361d3629858d119b9746b5e932c780c","tests/array.rs":"a57ae6264e676f573d7adb5c4b024994e98bc6811352516adb3444f880f7125e","tests/golang.rs":"284bed0d4c07857f33de96f2addc9a69c5688f864935a3e3e113c88c04bd826b","tests/iter.rs":"25dc02135bbae9d47a30f9047661648e66bdc134e40ba78bc2fbacbb8b3819bc","tests/list.rs":"3d1a4ae23bb6b4767242b8109a8efda26f1d3b28c0f90da3368f8eb9ca0eee37","tests/mpsc.rs":"d1e185c6290240132a34aa91221271225959f8652d7fc4ceb546ee9712361176","tests/never.rs":"ee40c4fc4dd5af4983fae8de6927f52b81174d222c162f745b26c4a6c7108e4f","tests/ready.rs":"d349702f123925a0781b48d677e6dcf64fc5d1fc788a7bf1e151a3d57e81871c","tests/same_channel.rs":"2bab761443671e841e1b2476bd8082d75533a2f6be7946f5dbcee67cdc82dccb","tests/select.rs":"ce12a8e0284fb9ccf6c1543bec309d9054193e6d942663aed19aa8499ef69c43","tests/select_macro.rs":"597d526fbd021ce70619d9172c931439f778ee3034ec1479aea461b65971a81a","tests/thread_locals.rs":"25ab70a8dcd8a0da9173e5476e17dcc8916caa5b68207d9c403655deaa8e8f4a","tests/tick.rs":"5f697bd14c48505d932e82065b5302ef668e1cc19cac18e8ac22e0c83c221c1d","tests/zero.rs":"9c5af802d5efb2c711f8242b8905ed29cc2601e48dbd95e41c7e6fbfe2918398"},"package":"c2dd04ddaf88237dc3b8d8f9a3c1004b506b54b3313403944054d23c0870c521"}
{"files":{"CHANGELOG.md":"6b520b783f5e0c17c6caa975defb9ed6e0ae1254a6a41a9bcd03d249bc942289","Cargo.lock":"605ed4a922e22b42c8a7b75624dfd55d6f0bc96bf76bbf016b003a2c44ddc29a","Cargo.toml":"0f7a8020ede552c5370c101973e8b77cdf5ce6d41f4b6f7b1420b97491fd1e24","LICENSE-APACHE":"a60eea817514531668d7e00765731449fe14d059d3249e0bc93b36de45f759f2","LICENSE-MIT":"5734ed989dfca1f625b40281ee9f4530f91b2411ec01cb748223e7eb87e201ab","LICENSE-THIRD-PARTY":"b16db96b93b1d7cf7bea533f572091ec6bca3234fbe0a83038be772ff391a44c","README.md":"5dfb91ebb498dec49948a440a53977109ec532388170e567c3c2a0339589aa4c","benches/crossbeam.rs":"96cb1abd23cac3ef8a7174a802e94609926b555bb02c9658c78723d433f1dd92","examples/fibonacci.rs":"4e88fa40048cdc31e9c7bb60347d46f92543d7ddf39cab3b52bfe44affdb6a02","examples/matching.rs":"63c250e164607a7a9f643d46f107bb5da846d49e89cf9069909562d20e530f71","examples/stopwatch.rs":"d02121258f08d56f1eb7997e19bcb9bacb6836cfa0abbba90a9e59d8a50ae5cf","src/channel.rs":"13fbbe12d4ec361855af1c3587fc80aea5f537db8dc44dd4f66c9e2b4ae9f5c1","src/context.rs":"477cc2b7bac7502fd2459288a58cc76f015b1ec8e87b853cda77ccb1808c6334","src/counter.rs":"b8f1e48ec634a7dab8e04c485209161587ecbbd2d57b0825467164d4554c6249","src/err.rs":"44cb2024ee6b0cd6fd24996430e53720769f64b4ac35016bc3e05cb9db48681d","src/flavors/array.rs":"79bc219187c9f40b156b9fe551c1176b66bf73e6d48905b23a2d74c6366a2205","src/flavors/at.rs":"04e07861534f2f7d5b5f884f2f5bc9c008427e6d0afa1c8ad401e1d7e54b57eb","src/flavors/list.rs":"280f55b51cefe9351a52c8d2186de368b688ad06885d083efe7e831726846520","src/flavors/mod.rs":"3d9d43bc38b0adb18c96c995c2bd3421d8e33ab6c30b20c3c467d21d48e485dc","src/flavors/never.rs":"747da857aa1a7601641f23f4930e6ad00ebaf50456d9be5c7aa270e2ecc24dcb","src/flavors/tick.rs":"0916ca3faef30b8cc591137701c456d5fc5b5b49cb1edad1e3a80d35bae222bb","src/flavors/zero.rs":"f9cbc9e035fadce808a4af86a223cfded89990ba1e9acfe731fb17a7fe12b432","src/lib.rs":"5b1c406fd1ce6140feae9000be361858da2aabe7fc9fffd0eafcb88020d2b268","src/select.rs":"7aa8addb82427141b0a4afa16fa4d23a02becab115a0a5a6d6d327728fd0672f","src/select_macro.rs":"522cfc8155825c1f260922c17ea6ef8ae672cf94863750c1a6115db2cbc9fc18","src/utils.rs":"9bd81aeb385a81409a63f4b9edc35444c7fd1d2724725f9c34ad7ca39dd69a18","src/waker.rs":"017f87a120d945502701c0dba79062c7fe55d44e5907cc6f8605b4510c90d529","tests/after.rs":"0154a8e152880db17a20514ecdd49dabc361d3629858d119b9746b5e932c780c","tests/array.rs":"a57ae6264e676f573d7adb5c4b024994e98bc6811352516adb3444f880f7125e","tests/golang.rs":"7b2ef219ba8a21841c133512f3a540f8279a2458304e9bbed7da81d6091ecd82","tests/iter.rs":"25dc02135bbae9d47a30f9047661648e66bdc134e40ba78bc2fbacbb8b3819bc","tests/list.rs":"3d1a4ae23bb6b4767242b8109a8efda26f1d3b28c0f90da3368f8eb9ca0eee37","tests/mpsc.rs":"5fbb5342fa7c9e4bcda5545255e0979dc6b9ba638edee127acf75372c18c925f","tests/never.rs":"ee40c4fc4dd5af4983fae8de6927f52b81174d222c162f745b26c4a6c7108e4f","tests/ready.rs":"4361352fa94254041e6c73e97b13be032c2d51c741f2a50519efe3000cf4dc28","tests/same_channel.rs":"2bab761443671e841e1b2476bd8082d75533a2f6be7946f5dbcee67cdc82dccb","tests/select.rs":"101ea8afd9a40d24c2d2aec29e5f2fdc4faac51aa1d7c9fe077b364f12edd206","tests/select_macro.rs":"4d6d52ad48f385c5b8f5023a590e00e7a4b632e80bd929b6fc89a53f5faee515","tests/thread_locals.rs":"f42fcddca959b3b44cd545b92949d65e33a54332b27f490ec92f9f29b7f8290c","tests/tick.rs":"5f697bd14c48505d932e82065b5302ef668e1cc19cac18e8ac22e0c83c221c1d","tests/zero.rs":"9c5af802d5efb2c711f8242b8905ed29cc2601e48dbd95e41c7e6fbfe2918398"},"package":"33480d6946193aa8033910124896ca395333cae7e2d1113d1fef6c3272217df2"}

View File

@@ -1,13 +1,50 @@
# Version 0.5.13
- Add `select_biased!` macro. (#1040)
# Version 0.5.12
- Fix memory leak in unbounded channel. (#1084)
# Version 0.5.11
- Remove dependency on `cfg-if`. (#1072)
# Version 0.5.10
- Relax the minimum supported Rust version to 1.60. (#1056)
- Optimize `Drop` implementation of bounded channel. (#1057)
# Version 0.5.9
- Bump the minimum supported Rust version to 1.61. (#1037)
# Version 0.5.8
- Fix race condition in unbounded channel. (#972)
# Version 0.5.7
**Note:** This release has been yanked due to bug fixed in 0.5.8.
- Improve handling of very large timeout. (#953)
# Version 0.5.6
**Note:** This release has been yanked due to bug fixed in 0.5.8.
- Bump the minimum supported Rust version to 1.38. (#877)
# Version 0.5.5
**Note:** This release has been yanked due to bug fixed in 0.5.8.
- Replace Spinlock with Mutex. (#835)
# Version 0.5.4
**Note:** This release has been yanked due to bug fixed in 0.5.8.
- Workaround a bug in upstream related to TLS access on AArch64 Linux. (#802)
# Version 0.5.3
@@ -24,6 +61,8 @@
# Version 0.5.1
**Note:** This release has been yanked due to bug fixed in 0.5.8.
- Fix memory leak in unbounded channel. (#669)
# Version 0.5.0

View File

@@ -10,9 +10,8 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "crossbeam-channel"
version = "0.5.6"
version = "0.5.13"
dependencies = [
"cfg-if",
"crossbeam-utils",
"num_cpus",
"rand",
@@ -21,19 +20,15 @@ dependencies = [
[[package]]
name = "crossbeam-utils"
version = "0.8.11"
version = "0.8.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "51887d4adc7b564537b15adcfb307936f8075dfcd5f00dde9a9f1d29383682bc"
dependencies = [
"cfg-if",
"once_cell",
]
checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345"
[[package]]
name = "getrandom"
version = "0.2.7"
version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6"
checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7"
dependencies = [
"cfg-if",
"libc",
@@ -42,40 +37,31 @@ dependencies = [
[[package]]
name = "hermit-abi"
version = "0.1.19"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
dependencies = [
"libc",
]
checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024"
[[package]]
name = "libc"
version = "0.2.126"
version = "0.2.154"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836"
checksum = "ae743338b92ff9146ce83992f766a31066a91a8c84a45e0e9f21e7cf6de6d346"
[[package]]
name = "num_cpus"
version = "1.13.1"
version = "1.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1"
checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43"
dependencies = [
"hermit-abi",
"libc",
]
[[package]]
name = "once_cell"
version = "1.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "18a6dbe30758c9f83eb00cbea4ac95966305f5a7772f3f42ebfc7fc7eddbd8e1"
[[package]]
name = "ppv-lite86"
version = "0.2.16"
version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872"
checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
[[package]]
name = "rand"
@@ -100,18 +86,18 @@ dependencies = [
[[package]]
name = "rand_core"
version = "0.6.3"
version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7"
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
dependencies = [
"getrandom",
]
[[package]]
name = "signal-hook"
version = "0.3.14"
version = "0.3.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a253b5e89e2698464fc26b545c9edceb338e18a89effeeecfea192c3025be29d"
checksum = "8621587d4798caf8eb44879d42e56b9a93ea5dcd315a6487c357130095b62801"
dependencies = [
"libc",
"signal-hook-registry",
@@ -119,9 +105,9 @@ dependencies = [
[[package]]
name = "signal-hook-registry"
version = "1.4.0"
version = "1.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0"
checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1"
dependencies = [
"libc",
]

View File

@@ -10,10 +10,10 @@
# See Cargo.toml.orig for the original contents.
[package]
edition = "2018"
rust-version = "1.38"
edition = "2021"
rust-version = "1.60"
name = "crossbeam-channel"
version = "0.5.6"
version = "0.5.13"
description = "Multi-producer multi-consumer channels for message passing"
homepage = "https://github.com/crossbeam-rs/crossbeam/tree/master/crossbeam-channel"
readme = "README.md"
@@ -32,12 +32,8 @@ categories = [
license = "MIT OR Apache-2.0"
repository = "https://github.com/crossbeam-rs/crossbeam"
[dependencies.cfg-if]
version = "1"
[dependencies.crossbeam-utils]
version = "0.8"
optional = true
version = "0.8.18"
default-features = false
[dev-dependencies.num_cpus]
@@ -52,3 +48,7 @@ version = "0.3"
[features]
default = ["std"]
std = ["crossbeam-utils/std"]
[lints.rust.unexpected_cfgs]
level = "warn"
priority = 0

View File

@@ -8,7 +8,7 @@ https://github.com/crossbeam-rs/crossbeam/tree/master/crossbeam-channel#license)
https://crates.io/crates/crossbeam-channel)
[![Documentation](https://docs.rs/crossbeam-channel/badge.svg)](
https://docs.rs/crossbeam-channel)
[![Rust 1.38+](https://img.shields.io/badge/rust-1.38+-lightgray.svg)](
[![Rust 1.60+](https://img.shields.io/badge/rust-1.60+-lightgray.svg)](
https://www.rust-lang.org)
[![chat](https://img.shields.io/discord/569610676205781012.svg?logo=discord)](https://discord.com/invite/JXYwgWZ)
@@ -48,7 +48,7 @@ crossbeam-channel = "0.5"
Crossbeam Channel supports stable Rust releases going back at least six months,
and every time the minimum supported Rust version is increased, a new minor
version is released. Currently, the minimum supported Rust version is 1.38.
version is released. Currently, the minimum supported Rust version is 1.60.
## License

View File

@@ -14,7 +14,6 @@ use crate::err::{
};
use crate::flavors;
use crate::select::{Operation, SelectHandle, Token};
use crate::utils;
/// Creates a channel of unbounded capacity.
///
@@ -160,7 +159,7 @@ pub fn bounded<T>(cap: usize) -> (Sender<T>, Receiver<T>) {
/// let ms = |ms| Duration::from_millis(ms);
///
/// // Returns `true` if `a` and `b` are very close `Instant`s.
/// let eq = |a, b| a + ms(50) > b && b + ms(50) > a;
/// let eq = |a, b| a + ms(60) > b && b + ms(60) > a;
///
/// let start = Instant::now();
/// let r = after(ms(100));
@@ -172,8 +171,11 @@ pub fn bounded<T>(cap: usize) -> (Sender<T>, Receiver<T>) {
/// assert!(eq(Instant::now(), start + ms(500)));
/// ```
pub fn after(duration: Duration) -> Receiver<Instant> {
Receiver {
flavor: ReceiverFlavor::At(Arc::new(flavors::at::Channel::new_timeout(duration))),
match Instant::now().checked_add(duration) {
Some(deadline) => Receiver {
flavor: ReceiverFlavor::At(Arc::new(flavors::at::Channel::new_deadline(deadline))),
},
None => never(),
}
}
@@ -320,8 +322,14 @@ pub fn never<T>() -> Receiver<T> {
/// assert!(eq(Instant::now(), start + ms(700)));
/// ```
pub fn tick(duration: Duration) -> Receiver<Instant> {
Receiver {
flavor: ReceiverFlavor::Tick(Arc::new(flavors::tick::Channel::new(duration))),
match Instant::now().checked_add(duration) {
Some(delivery_time) => Receiver {
flavor: ReceiverFlavor::Tick(Arc::new(flavors::tick::Channel::new(
delivery_time,
duration,
))),
},
None => never(),
}
}
@@ -474,7 +482,10 @@ impl<T> Sender<T> {
/// );
/// ```
pub fn send_timeout(&self, msg: T, timeout: Duration) -> Result<(), SendTimeoutError<T>> {
self.send_deadline(msg, utils::convert_timeout_to_deadline(timeout))
match Instant::now().checked_add(timeout) {
Some(deadline) => self.send_deadline(msg, deadline),
None => self.send(msg).map_err(SendTimeoutError::from),
}
}
/// Waits for a message to be sent into the channel, but only until a given deadline.
@@ -864,7 +875,10 @@ impl<T> Receiver<T> {
/// );
/// ```
pub fn recv_timeout(&self, timeout: Duration) -> Result<T, RecvTimeoutError> {
self.recv_deadline(utils::convert_timeout_to_deadline(timeout))
match Instant::now().checked_add(timeout) {
Some(deadline) => self.recv_deadline(deadline),
None => self.recv().map_err(RecvTimeoutError::from),
}
}
/// Waits for a message to be received from the channel, but only before a given deadline.

View File

@@ -41,7 +41,7 @@ impl Context {
where
F: FnOnce(&Context) -> R,
{
thread_local! {
std::thread_local! {
/// Cached thread-local context.
static CONTEXT: Cell<Option<Context>> = Cell::new(Some(Context::new()));
}

View File

@@ -1,5 +1,6 @@
//! Reference counter for channels.
use std::boxed::Box;
use std::isize;
use std::ops;
use std::process;

View File

@@ -8,8 +8,9 @@
//! - <http://www.1024cores.net/home/lock-free-algorithms/queues/bounded-mpmc-queue>
//! - <https://docs.google.com/document/d/1yIAYmbvL3JxOKOjuCyon7JhW4cSv1wy5hC0ApeGMV9s/pub>
use std::boxed::Box;
use std::cell::UnsafeCell;
use std::mem::MaybeUninit;
use std::mem::{self, MaybeUninit};
use std::ptr;
use std::sync::atomic::{self, AtomicUsize, Ordering};
use std::time::Instant;
@@ -242,7 +243,7 @@ impl<T> Channel<T> {
let slot = unsafe { self.buffer.get_unchecked(index) };
let stamp = slot.stamp.load(Ordering::Acquire);
// If the the stamp is ahead of the head by 1, we may attempt to pop.
// If the stamp is ahead of the head by 1, we may attempt to pop.
if head + 1 == stamp {
let new = if index + 1 < self.cap {
// Same lap, incremented index.
@@ -520,37 +521,38 @@ impl<T> Channel<T> {
impl<T> Drop for Channel<T> {
fn drop(&mut self) {
// Get the index of the head.
let head = *self.head.get_mut();
let tail = *self.tail.get_mut();
if mem::needs_drop::<T>() {
// Get the index of the head.
let head = *self.head.get_mut();
let tail = *self.tail.get_mut();
let hix = head & (self.mark_bit - 1);
let tix = tail & (self.mark_bit - 1);
let hix = head & (self.mark_bit - 1);
let tix = tail & (self.mark_bit - 1);
let len = if hix < tix {
tix - hix
} else if hix > tix {
self.cap - hix + tix
} else if (tail & !self.mark_bit) == head {
0
} else {
self.cap
};
// Loop over all slots that hold a message and drop them.
for i in 0..len {
// Compute the index of the next slot holding a message.
let index = if hix + i < self.cap {
hix + i
let len = if hix < tix {
tix - hix
} else if hix > tix {
self.cap - hix + tix
} else if (tail & !self.mark_bit) == head {
0
} else {
hix + i - self.cap
self.cap
};
unsafe {
debug_assert!(index < self.buffer.len());
let slot = self.buffer.get_unchecked_mut(index);
let msg = &mut *slot.msg.get();
msg.as_mut_ptr().drop_in_place();
// Loop over all slots that hold a message and drop them.
for i in 0..len {
// Compute the index of the next slot holding a message.
let index = if hix + i < self.cap {
hix + i
} else {
hix + i - self.cap
};
unsafe {
debug_assert!(index < self.buffer.len());
let slot = self.buffer.get_unchecked_mut(index);
(*slot.msg.get()).assume_init_drop();
}
}
}
}

View File

@@ -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]

View File

@@ -1,5 +1,6 @@
//! Unbounded channel implemented as a linked list.
use std::boxed::Box;
use std::cell::UnsafeCell;
use std::marker::PhantomData;
use std::mem::MaybeUninit;
@@ -582,7 +583,22 @@ impl<T> Channel<T> {
}
let mut head = self.head.index.load(Ordering::Acquire);
let mut block = self.head.block.load(Ordering::Acquire);
// The channel may be uninitialized, so we have to swap to avoid overwriting any sender's attempts
// to initialize the first block before noticing that the receivers disconnected. Late allocations
// will be deallocated by the sender in Drop
let mut block = self.head.block.swap(ptr::null_mut(), Ordering::AcqRel);
// 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.
@@ -593,8 +609,7 @@ impl<T> Channel<T> {
// Drop the message in the slot.
let slot = (*block).slots.get_unchecked(offset);
slot.wait_write();
let p = &mut *slot.msg.get();
p.as_mut_ptr().drop_in_place();
(*slot.msg.get()).assume_init_drop();
} else {
(*block).wait_next();
// Deallocate the block and move to the next one.
@@ -612,7 +627,6 @@ impl<T> Channel<T> {
}
}
head &= !MARK_BIT;
self.head.block.store(ptr::null_mut(), Ordering::Release);
self.head.index.store(head, Ordering::Release);
}
@@ -652,8 +666,7 @@ impl<T> Drop for Channel<T> {
if offset < BLOCK_CAP {
// Drop the message in the slot.
let slot = (*block).slots.get_unchecked(offset);
let p = &mut *slot.msg.get();
p.as_mut_ptr().drop_in_place();
(*slot.msg.get()).assume_init_drop();
} else {
// Deallocate the block and move to the next one.
let next = *(*block).next.get_mut();

View File

@@ -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,
}
}

View File

@@ -2,6 +2,7 @@
//!
//! This kind of channel is also known as *rendezvous* channel.
use std::boxed::Box;
use std::cell::UnsafeCell;
use std::marker::PhantomData;
use std::sync::atomic::{AtomicBool, Ordering};

View File

@@ -321,6 +321,7 @@
//! [`iter`]: Receiver::iter
//! [`try_iter`]: Receiver::try_iter
#![no_std]
#![doc(test(
no_crate_inject,
attr(
@@ -334,38 +335,44 @@
rust_2018_idioms,
unreachable_pub
)]
#![cfg_attr(not(feature = "std"), no_std)]
use cfg_if::cfg_if;
#[cfg(feature = "std")]
extern crate std;
cfg_if! {
if #[cfg(feature = "std")] {
mod channel;
mod context;
mod counter;
mod err;
mod flavors;
mod select;
mod select_macro;
mod utils;
mod waker;
#[cfg(feature = "std")]
mod channel;
#[cfg(feature = "std")]
mod context;
#[cfg(feature = "std")]
mod counter;
#[cfg(feature = "std")]
mod err;
#[cfg(feature = "std")]
mod flavors;
#[cfg(feature = "std")]
mod select;
#[cfg(feature = "std")]
mod select_macro;
#[cfg(feature = "std")]
mod utils;
#[cfg(feature = "std")]
mod waker;
/// Crate internals used by the `select!` macro.
#[doc(hidden)]
pub mod internal {
pub use crate::select::SelectHandle;
pub use crate::select::{select, select_timeout, try_select};
}
pub use crate::channel::{after, at, never, tick};
pub use crate::channel::{bounded, unbounded};
pub use crate::channel::{IntoIter, Iter, TryIter};
pub use crate::channel::{Receiver, Sender};
pub use crate::select::{Select, SelectedOperation};
pub use crate::err::{ReadyTimeoutError, SelectTimeoutError, TryReadyError, TrySelectError};
pub use crate::err::{RecvError, RecvTimeoutError, TryRecvError};
pub use crate::err::{SendError, SendTimeoutError, TrySendError};
}
/// Crate internals used by the `select!` macro.
#[doc(hidden)]
#[cfg(feature = "std")]
pub mod internal {
pub use crate::select::{select, select_timeout, try_select, SelectHandle};
}
#[cfg(feature = "std")]
pub use crate::{
channel::{
after, at, bounded, never, tick, unbounded, IntoIter, Iter, Receiver, Sender, TryIter,
},
err::{
ReadyTimeoutError, RecvError, RecvTimeoutError, SelectTimeoutError, SendError,
SendTimeoutError, TryReadyError, TryRecvError, TrySelectError, TrySendError,
},
select::{Select, SelectedOperation},
};

View File

@@ -4,6 +4,7 @@ use std::fmt;
use std::marker::PhantomData;
use std::mem;
use std::time::{Duration, Instant};
use std::vec::Vec;
use crossbeam_utils::Backoff;
@@ -176,6 +177,7 @@ enum Timeout {
fn run_select(
handles: &mut [(&dyn SelectHandle, usize, *const u8)],
timeout: Timeout,
is_biased: bool,
) -> Option<(Token, usize, *const u8)> {
if handles.is_empty() {
// Wait until the timeout and return.
@@ -192,8 +194,10 @@ fn run_select(
}
}
// Shuffle the operations for fairness.
utils::shuffle(handles);
if !is_biased {
// Shuffle the operations for fairness.
utils::shuffle(handles);
}
// Create a token, which serves as a temporary variable that gets initialized in this function
// and is later used by a call to `channel::read()` or `channel::write()` that completes the
@@ -324,6 +328,7 @@ fn run_select(
fn run_ready(
handles: &mut [(&dyn SelectHandle, usize, *const u8)],
timeout: Timeout,
is_biased: bool,
) -> Option<usize> {
if handles.is_empty() {
// Wait until the timeout and return.
@@ -340,8 +345,10 @@ fn run_ready(
}
}
// Shuffle the operations for fairness.
utils::shuffle(handles);
if !is_biased {
// Shuffle the operations for fairness.
utils::shuffle(handles);
}
loop {
let backoff = Backoff::new();
@@ -449,8 +456,9 @@ fn run_ready(
#[inline]
pub fn try_select<'a>(
handles: &mut [(&'a dyn SelectHandle, usize, *const u8)],
is_biased: bool,
) -> Result<SelectedOperation<'a>, TrySelectError> {
match run_select(handles, Timeout::Now) {
match run_select(handles, Timeout::Now, is_biased) {
None => Err(TrySelectError),
Some((token, index, ptr)) => Ok(SelectedOperation {
token,
@@ -466,12 +474,13 @@ pub fn try_select<'a>(
#[inline]
pub fn select<'a>(
handles: &mut [(&'a dyn SelectHandle, usize, *const u8)],
is_biased: bool,
) -> SelectedOperation<'a> {
if handles.is_empty() {
panic!("no operations have been added to `Select`");
}
let (token, index, ptr) = run_select(handles, Timeout::Never).unwrap();
let (token, index, ptr) = run_select(handles, Timeout::Never, is_biased).unwrap();
SelectedOperation {
token,
index,
@@ -486,8 +495,12 @@ pub fn select<'a>(
pub fn select_timeout<'a>(
handles: &mut [(&'a dyn SelectHandle, usize, *const u8)],
timeout: Duration,
is_biased: bool,
) -> Result<SelectedOperation<'a>, SelectTimeoutError> {
select_deadline(handles, utils::convert_timeout_to_deadline(timeout))
match Instant::now().checked_add(timeout) {
Some(deadline) => select_deadline(handles, deadline, is_biased),
None => Ok(select(handles, is_biased)),
}
}
/// Blocks until a given deadline, or until one of the operations becomes ready and selects it.
@@ -495,8 +508,9 @@ pub fn select_timeout<'a>(
pub(crate) fn select_deadline<'a>(
handles: &mut [(&'a dyn SelectHandle, usize, *const u8)],
deadline: Instant,
is_biased: bool,
) -> Result<SelectedOperation<'a>, SelectTimeoutError> {
match run_select(handles, Timeout::At(deadline)) {
match run_select(handles, Timeout::At(deadline), is_biased) {
None => Err(SelectTimeoutError),
Some((token, index, ptr)) => Ok(SelectedOperation {
token,
@@ -760,7 +774,7 @@ impl<'a> Select<'a> {
/// }
/// ```
pub fn try_select(&mut self) -> Result<SelectedOperation<'a>, TrySelectError> {
try_select(&mut self.handles)
try_select(&mut self.handles, false)
}
/// Blocks until one of the operations becomes ready and selects it.
@@ -807,7 +821,7 @@ impl<'a> Select<'a> {
/// }
/// ```
pub fn select(&mut self) -> SelectedOperation<'a> {
select(&mut self.handles)
select(&mut self.handles, false)
}
/// Blocks for a limited time until one of the operations becomes ready and selects it.
@@ -857,7 +871,7 @@ impl<'a> Select<'a> {
&mut self,
timeout: Duration,
) -> Result<SelectedOperation<'a>, SelectTimeoutError> {
select_timeout(&mut self.handles, timeout)
select_timeout(&mut self.handles, timeout, false)
}
/// Blocks until a given deadline, or until one of the operations becomes ready and selects it.
@@ -909,7 +923,7 @@ impl<'a> Select<'a> {
&mut self,
deadline: Instant,
) -> Result<SelectedOperation<'a>, SelectTimeoutError> {
select_deadline(&mut self.handles, deadline)
select_deadline(&mut self.handles, deadline, false)
}
/// Attempts to find a ready operation without blocking.
@@ -948,7 +962,7 @@ impl<'a> Select<'a> {
/// }
/// ```
pub fn try_ready(&mut self) -> Result<usize, TryReadyError> {
match run_ready(&mut self.handles, Timeout::Now) {
match run_ready(&mut self.handles, Timeout::Now, false) {
None => Err(TryReadyError),
Some(index) => Ok(index),
}
@@ -1001,7 +1015,7 @@ impl<'a> Select<'a> {
panic!("no operations have been added to `Select`");
}
run_ready(&mut self.handles, Timeout::Never).unwrap()
run_ready(&mut self.handles, Timeout::Never, false).unwrap()
}
/// Blocks for a limited time until one of the operations becomes ready.
@@ -1045,7 +1059,10 @@ impl<'a> Select<'a> {
/// }
/// ```
pub fn ready_timeout(&mut self, timeout: Duration) -> Result<usize, ReadyTimeoutError> {
self.ready_deadline(utils::convert_timeout_to_deadline(timeout))
match Instant::now().checked_add(timeout) {
Some(deadline) => self.ready_deadline(deadline),
None => Ok(self.ready()),
}
}
/// Blocks until a given deadline, or until one of the operations becomes ready.
@@ -1091,7 +1108,7 @@ impl<'a> Select<'a> {
/// }
/// ```
pub fn ready_deadline(&mut self, deadline: Instant) -> Result<usize, ReadyTimeoutError> {
match run_ready(&mut self.handles, Timeout::At(deadline)) {
match run_ready(&mut self.handles, Timeout::At(deadline), false) {
None => Err(ReadyTimeoutError),
Some(index) => Ok(index),
}

View File

@@ -685,7 +685,7 @@ macro_rules! crossbeam_channel_internal {
$default:tt
) => {{
const _LEN: usize = $crate::crossbeam_channel_internal!(@count ($($cases)*));
let _handle: &$crate::internal::SelectHandle = &$crate::never::<()>();
let _handle: &dyn $crate::internal::SelectHandle = &$crate::never::<()>();
#[allow(unused_mut)]
let mut _sel = [(_handle, 0, ::std::ptr::null()); _LEN];
@@ -750,7 +750,7 @@ macro_rules! crossbeam_channel_internal {
$cases:tt
) => {{
let _oper: $crate::SelectedOperation<'_> = {
let _oper = $crate::internal::select(&mut $sel);
let _oper = $crate::internal::select(&mut $sel, _IS_BIASED);
// Erase the lifetime so that `sel` can be dropped early even without NLL.
unsafe { ::std::mem::transmute(_oper) }
@@ -772,7 +772,7 @@ macro_rules! crossbeam_channel_internal {
$cases:tt
) => {{
let _oper: ::std::option::Option<$crate::SelectedOperation<'_>> = {
let _oper = $crate::internal::try_select(&mut $sel);
let _oper = $crate::internal::try_select(&mut $sel, _IS_BIASED);
// Erase the lifetime so that `sel` can be dropped early even without NLL.
unsafe { ::std::mem::transmute(_oper) }
@@ -802,7 +802,7 @@ macro_rules! crossbeam_channel_internal {
$cases:tt
) => {{
let _oper: ::std::option::Option<$crate::SelectedOperation<'_>> = {
let _oper = $crate::internal::select_timeout(&mut $sel, $timeout);
let _oper = $crate::internal::select_timeout(&mut $sel, $timeout, _IS_BIASED);
// Erase the lifetime so that `sel` can be dropped early even without NLL.
unsafe { ::std::mem::transmute(_oper) }
@@ -985,7 +985,8 @@ macro_rules! crossbeam_channel_internal {
///
/// This macro allows you to define a set of channel operations, wait until any one of them becomes
/// ready, and finally execute it. If multiple operations are ready at the same time, a random one
/// among them is selected.
/// among them is selected (i.e. the unbiased selection). Use `select_biased!` for the biased
/// selection.
///
/// It is also possible to define a `default` case that gets executed if none of the operations are
/// ready, either right away or for a certain duration of time.
@@ -1109,8 +1110,33 @@ macro_rules! crossbeam_channel_internal {
#[macro_export]
macro_rules! select {
($($tokens:tt)*) => {
$crate::crossbeam_channel_internal!(
$($tokens)*
)
{
const _IS_BIASED: bool = false;
$crate::crossbeam_channel_internal!(
$($tokens)*
)
}
};
}
/// Selects from a set of channel operations.
///
/// This macro allows you to define a list of channel operations, wait until any one of them
/// becomes ready, and finally execute it. If multiple operations are ready at the same time, the
/// operation nearest to the front of the list is always selected (i.e. the biased selection). Use
/// [`select!`] for the unbiased selection.
///
/// Otherwise, this macro's functionality is identical to [`select!`]. Refer to it for the syntax.
#[macro_export]
macro_rules! select_biased {
($($tokens:tt)*) => {
{
const _IS_BIASED: bool = true;
$crate::crossbeam_channel_internal!(
$($tokens)*
)
}
};
}

View File

@@ -12,8 +12,8 @@ pub(crate) fn shuffle<T>(v: &mut [T]) {
return;
}
thread_local! {
static RNG: Cell<Wrapping<u32>> = Cell::new(Wrapping(1_406_868_647));
std::thread_local! {
static RNG: Cell<Wrapping<u32>> = const { Cell::new(Wrapping(1_406_868_647)) };
}
let _ = RNG.try_with(|rng| {
@@ -56,11 +56,3 @@ pub(crate) fn sleep_until(deadline: Option<Instant>) {
}
}
}
// https://github.com/crossbeam-rs/crossbeam/issues/795
pub(crate) fn convert_timeout_to_deadline(timeout: Duration) -> Instant {
match Instant::now().checked_add(timeout) {
Some(deadline) => deadline,
None => Instant::now() + Duration::from_secs(86400 * 365 * 30),
}
}

View File

@@ -4,6 +4,7 @@ use std::ptr;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Mutex;
use std::thread::{self, ThreadId};
use std::vec::Vec;
use crate::context::Context;
use crate::select::{Operation, Selected};
@@ -275,7 +276,7 @@ impl Drop for SyncWaker {
/// Returns the id of the current thread.
#[inline]
fn current_thread_id() -> ThreadId {
thread_local! {
std::thread_local! {
/// Cached thread-local id.
static THREAD_ID: ThreadId = thread::current().id();
}

View File

@@ -9,7 +9,7 @@
//! - https://golang.org/LICENSE
//! - https://golang.org/PATENTS
#![allow(clippy::mutex_atomic, clippy::redundant_clone)]
#![allow(clippy::redundant_clone)]
use std::alloc::{GlobalAlloc, Layout, System};
use std::any::Any;

View File

@@ -20,11 +20,7 @@
//! - https://github.com/rust-lang/rust/blob/master/COPYRIGHT
//! - https://www.rust-lang.org/en-US/legal.html
#![allow(
clippy::drop_copy,
clippy::match_single_binding,
clippy::redundant_clone
)]
#![allow(clippy::match_single_binding, clippy::redundant_clone)]
use std::sync::mpsc::{RecvError, RecvTimeoutError, TryRecvError};
use std::sync::mpsc::{SendError, TrySendError};
@@ -180,6 +176,8 @@ macro_rules! select {
(
$($name:pat = $rx:ident.$meth:ident() => $code:expr),+
) => ({
const _IS_BIASED: bool = false;
cc::crossbeam_channel_internal! {
$(
$meth(($rx).inner) -> res => {
@@ -197,7 +195,7 @@ mod channel_tests {
use std::env;
use std::thread;
use std::time::{Duration, Instant};
use std::time::Instant;
pub fn stress_factor() -> usize {
match env::var("RUST_TEST_STRESS") {
@@ -973,7 +971,6 @@ mod sync_channel_tests {
use std::env;
use std::thread;
use std::time::Duration;
pub fn stress_factor() -> usize {
match env::var("RUST_TEST_STRESS") {

View File

@@ -1,7 +1,5 @@
//! Tests for channel readiness using the `Select` struct.
#![allow(clippy::drop_copy)]
use std::any::Any;
use std::cell::Cell;
use std::thread;
@@ -229,6 +227,7 @@ fn default_when_disconnected() {
}
#[test]
#[cfg_attr(miri, ignore)] // this test makes timing assumptions, but Miri is so slow it violates them
fn default_only() {
let start = Instant::now();

View File

@@ -1,7 +1,5 @@
//! Tests for channel selection using the `Select` struct.
#![allow(clippy::drop_copy)]
use std::any::Any;
use std::cell::Cell;
use std::thread;

View File

@@ -1,7 +1,7 @@
//! Tests for the `select!` macro.
#![forbid(unsafe_code)] // select! is safe.
#![allow(clippy::drop_copy, clippy::match_single_binding)]
#![allow(clippy::match_single_binding)]
use std::any::Any;
use std::cell::Cell;
@@ -9,7 +9,7 @@ use std::ops::Deref;
use std::thread;
use std::time::{Duration, Instant};
use crossbeam_channel::{after, bounded, never, select, tick, unbounded};
use crossbeam_channel::{after, bounded, never, select, select_biased, tick, unbounded};
use crossbeam_channel::{Receiver, RecvError, SendError, Sender, TryRecvError};
use crossbeam_utils::thread::scope;
@@ -943,7 +943,122 @@ fn fairness_send() {
assert!(hits.iter().all(|x| *x >= COUNT / 4));
}
#[allow(clippy::or_fun_call)] // This is intentional.
#[test]
fn unfairness() {
#[cfg(miri)]
const COUNT: usize = 100;
#[cfg(not(miri))]
const COUNT: usize = 10_000;
let (s1, r1) = unbounded::<()>();
let (s2, r2) = unbounded::<()>();
let (s3, r3) = unbounded::<()>();
for _ in 0..COUNT {
s1.send(()).unwrap();
s2.send(()).unwrap();
}
s3.send(()).unwrap();
let mut hits = [0usize; 3];
for _ in 0..COUNT {
select_biased! {
recv(r1) -> _ => hits[0] += 1,
recv(r2) -> _ => hits[1] += 1,
recv(r3) -> _ => hits[2] += 1,
}
}
assert_eq!(hits, [COUNT, 0, 0]);
for _ in 0..COUNT {
select_biased! {
recv(r1) -> _ => hits[0] += 1,
recv(r2) -> _ => hits[1] += 1,
recv(r3) -> _ => hits[2] += 1,
}
}
assert_eq!(hits, [COUNT, COUNT, 0]);
}
#[test]
fn unfairness_timeout() {
#[cfg(miri)]
const COUNT: usize = 100;
#[cfg(not(miri))]
const COUNT: usize = 10_000;
let (s1, r1) = unbounded::<()>();
let (s2, r2) = unbounded::<()>();
let (s3, r3) = unbounded::<()>();
for _ in 0..COUNT {
s1.send(()).unwrap();
s2.send(()).unwrap();
}
s3.send(()).unwrap();
let mut hits = [0usize; 3];
for _ in 0..COUNT {
select_biased! {
recv(r1) -> _ => hits[0] += 1,
recv(r2) -> _ => hits[1] += 1,
recv(r3) -> _ => hits[2] += 1,
default(ms(1000)) => unreachable!(),
}
}
assert_eq!(hits, [COUNT, 0, 0]);
for _ in 0..COUNT {
select_biased! {
recv(r1) -> _ => hits[0] += 1,
recv(r2) -> _ => hits[1] += 1,
recv(r3) -> _ => hits[2] += 1,
default(ms(1000)) => unreachable!(),
}
}
assert_eq!(hits, [COUNT, COUNT, 0]);
}
#[test]
fn unfairness_try() {
#[cfg(miri)]
const COUNT: usize = 100;
#[cfg(not(miri))]
const COUNT: usize = 10_000;
let (s1, r1) = unbounded::<()>();
let (s2, r2) = unbounded::<()>();
let (s3, r3) = unbounded::<()>();
for _ in 0..COUNT {
s1.send(()).unwrap();
s2.send(()).unwrap();
}
s3.send(()).unwrap();
let mut hits = [0usize; 3];
for _ in 0..COUNT {
select_biased! {
recv(r1) -> _ => hits[0] += 1,
recv(r2) -> _ => hits[1] += 1,
recv(r3) -> _ => hits[2] += 1,
default() => unreachable!(),
}
}
assert_eq!(hits, [COUNT, 0, 0]);
for _ in 0..COUNT {
select_biased! {
recv(r1) -> _ => hits[0] += 1,
recv(r2) -> _ => hits[1] += 1,
recv(r3) -> _ => hits[2] += 1,
default() => unreachable!(),
}
}
assert_eq!(hits, [COUNT, COUNT, 0]);
}
#[allow(clippy::or_fun_call, clippy::unnecessary_literal_unwrap)] // This is intentional.
#[test]
fn references() {
let (s, r) = unbounded::<i32>();
@@ -1212,32 +1327,32 @@ fn result_types() {
let (_, r) = bounded::<i32>(0);
select! {
recv(r) -> res => drop::<Result<i32, RecvError>>(res),
recv(r) -> res => { let _: Result<i32, RecvError> = res; },
}
select! {
recv(r) -> res => drop::<Result<i32, RecvError>>(res),
recv(r) -> res => { let _: Result<i32, RecvError> = res; },
default => {}
}
select! {
recv(r) -> res => drop::<Result<i32, RecvError>>(res),
recv(r) -> res => { let _: Result<i32, RecvError> = res; },
default(ms(0)) => {}
}
select! {
send(s, 0) -> res => drop::<Result<(), SendError<i32>>>(res),
send(s, 0) -> res => { let _: Result<(), SendError<i32>> = res; },
}
select! {
send(s, 0) -> res => drop::<Result<(), SendError<i32>>>(res),
send(s, 0) -> res => { let _: Result<(), SendError<i32>> = res; },
default => {}
}
select! {
send(s, 0) -> res => drop::<Result<(), SendError<i32>>>(res),
send(s, 0) -> res => { let _: Result<(), SendError<i32>> = res; },
default(ms(0)) => {}
}
select! {
send(s, 0) -> res => drop::<Result<(), SendError<i32>>>(res),
recv(r) -> res => drop::<Result<i32, RecvError>>(res),
send(s, 0) -> res => { let _: Result<(), SendError<i32>> = res; },
recv(r) -> res => { let _: Result<i32, RecvError> = res; },
}
}

View File

@@ -30,7 +30,7 @@ fn use_while_exiting() {
}
thread_local! {
static FOO: Foo = Foo;
static FOO: Foo = const { Foo };
}
let (s, r) = unbounded::<()>();