List of all items[−]
+ Crate crossbeam_channel
Version 0.5.4
Back to index
\ No newline at end of file
diff --git a/rustdoc/crossbeam_channel/index.html b/rustdoc/crossbeam_channel/index.html
index 5c610377..a6b6554d 100644
--- a/rustdoc/crossbeam_channel/index.html
+++ b/rustdoc/crossbeam_channel/index.html
@@ -1,6 +1,6 @@
crossbeam_channel - Rust
Crate crossbeam_channel[−][src]
Expand description
Multi-producer multi-consumer channels for message passing.
+ Crate crossbeam_channel
Version 0.5.4
Crate crossbeam_channel[−][src]
Expand description
Multi-producer multi-consumer channels for message passing.
This crate is an alternative to std::sync::mpsc
with more features and better performance.
Hello, world!
use crossbeam_channel::unbounded;
diff --git a/rustdoc/src/crossbeam_channel/channel.rs.html b/rustdoc/src/crossbeam_channel/channel.rs.html
index c2d53b5e..29441fe3 100644
--- a/rustdoc/src/crossbeam_channel/channel.rs.html
+++ b/rustdoc/src/crossbeam_channel/channel.rs.html
@@ -1,4 +1,4 @@
-channel.rs - source
+channel.rs - source
1
2
diff --git a/rustdoc/src/crossbeam_channel/context.rs.html b/rustdoc/src/crossbeam_channel/context.rs.html
index 5d280570..608dd2a3 100644
--- a/rustdoc/src/crossbeam_channel/context.rs.html
+++ b/rustdoc/src/crossbeam_channel/context.rs.html
@@ -1,4 +1,4 @@
-context.rs - source
+context.rs - source
1
2
diff --git a/rustdoc/src/crossbeam_channel/counter.rs.html b/rustdoc/src/crossbeam_channel/counter.rs.html
index 4e1f9c57..9c7f3b96 100644
--- a/rustdoc/src/crossbeam_channel/counter.rs.html
+++ b/rustdoc/src/crossbeam_channel/counter.rs.html
@@ -1,4 +1,4 @@
-counter.rs - source
+counter.rs - source
1
2
diff --git a/rustdoc/src/crossbeam_channel/err.rs.html b/rustdoc/src/crossbeam_channel/err.rs.html
index 0d36a2f7..4154c777 100644
--- a/rustdoc/src/crossbeam_channel/err.rs.html
+++ b/rustdoc/src/crossbeam_channel/err.rs.html
@@ -1,4 +1,4 @@
-err.rs - source
+err.rs - source
1
2
diff --git a/rustdoc/src/crossbeam_channel/flavors/array.rs.html b/rustdoc/src/crossbeam_channel/flavors/array.rs.html
index 8a0ba06f..974ab916 100644
--- a/rustdoc/src/crossbeam_channel/flavors/array.rs.html
+++ b/rustdoc/src/crossbeam_channel/flavors/array.rs.html
@@ -1,4 +1,4 @@
-array.rs - source
+array.rs - source
1
2
diff --git a/rustdoc/src/crossbeam_channel/flavors/at.rs.html b/rustdoc/src/crossbeam_channel/flavors/at.rs.html
index 91578874..bec6b53b 100644
--- a/rustdoc/src/crossbeam_channel/flavors/at.rs.html
+++ b/rustdoc/src/crossbeam_channel/flavors/at.rs.html
@@ -1,4 +1,4 @@
-at.rs - source
+at.rs - source
1
2
diff --git a/rustdoc/src/crossbeam_channel/flavors/list.rs.html b/rustdoc/src/crossbeam_channel/flavors/list.rs.html
index 75ca7d2d..15600ff4 100644
--- a/rustdoc/src/crossbeam_channel/flavors/list.rs.html
+++ b/rustdoc/src/crossbeam_channel/flavors/list.rs.html
@@ -1,4 +1,4 @@
-list.rs - source
+list.rs - source
1
2
diff --git a/rustdoc/src/crossbeam_channel/flavors/mod.rs.html b/rustdoc/src/crossbeam_channel/flavors/mod.rs.html
index 061ccb8c..e7df4711 100644
--- a/rustdoc/src/crossbeam_channel/flavors/mod.rs.html
+++ b/rustdoc/src/crossbeam_channel/flavors/mod.rs.html
@@ -1,4 +1,4 @@
-mod.rs - source
+mod.rs - source
1
2
diff --git a/rustdoc/src/crossbeam_channel/flavors/never.rs.html b/rustdoc/src/crossbeam_channel/flavors/never.rs.html
index c4f60dd0..8ac968b6 100644
--- a/rustdoc/src/crossbeam_channel/flavors/never.rs.html
+++ b/rustdoc/src/crossbeam_channel/flavors/never.rs.html
@@ -1,4 +1,4 @@
-never.rs - source
+never.rs - source
1
2
diff --git a/rustdoc/src/crossbeam_channel/flavors/tick.rs.html b/rustdoc/src/crossbeam_channel/flavors/tick.rs.html
index c8efbd9f..e4873a6e 100644
--- a/rustdoc/src/crossbeam_channel/flavors/tick.rs.html
+++ b/rustdoc/src/crossbeam_channel/flavors/tick.rs.html
@@ -1,4 +1,4 @@
-tick.rs - source
+tick.rs - source
1
2
diff --git a/rustdoc/src/crossbeam_channel/flavors/zero.rs.html b/rustdoc/src/crossbeam_channel/flavors/zero.rs.html
index 70f4eeb7..c12694b4 100644
--- a/rustdoc/src/crossbeam_channel/flavors/zero.rs.html
+++ b/rustdoc/src/crossbeam_channel/flavors/zero.rs.html
@@ -1,4 +1,4 @@
-zero.rs - source
+zero.rs - source
1
2
diff --git a/rustdoc/src/crossbeam_channel/lib.rs.html b/rustdoc/src/crossbeam_channel/lib.rs.html
index c6f4f56c..23db3323 100644
--- a/rustdoc/src/crossbeam_channel/lib.rs.html
+++ b/rustdoc/src/crossbeam_channel/lib.rs.html
@@ -1,4 +1,4 @@
-lib.rs - source
+lib.rs - source
1
2
diff --git a/rustdoc/src/crossbeam_channel/select.rs.html b/rustdoc/src/crossbeam_channel/select.rs.html
index 849e0adc..e1c7770d 100644
--- a/rustdoc/src/crossbeam_channel/select.rs.html
+++ b/rustdoc/src/crossbeam_channel/select.rs.html
@@ -1,4 +1,4 @@
-select.rs - source
+select.rs - source
1
2
diff --git a/rustdoc/src/crossbeam_channel/select_macro.rs.html b/rustdoc/src/crossbeam_channel/select_macro.rs.html
index bd85d71a..ecda11dc 100644
--- a/rustdoc/src/crossbeam_channel/select_macro.rs.html
+++ b/rustdoc/src/crossbeam_channel/select_macro.rs.html
@@ -1,4 +1,4 @@
-select_macro.rs - source
+select_macro.rs - source
1
2
diff --git a/rustdoc/src/crossbeam_channel/utils.rs.html b/rustdoc/src/crossbeam_channel/utils.rs.html
index 1d7f4bce..9896fa20 100644
--- a/rustdoc/src/crossbeam_channel/utils.rs.html
+++ b/rustdoc/src/crossbeam_channel/utils.rs.html
@@ -1,4 +1,4 @@
-utils.rs - source
+utils.rs - source
1
2
diff --git a/rustdoc/src/crossbeam_channel/waker.rs.html b/rustdoc/src/crossbeam_channel/waker.rs.html
index 9c7bcaa7..3382c5e2 100644
--- a/rustdoc/src/crossbeam_channel/waker.rs.html
+++ b/rustdoc/src/crossbeam_channel/waker.rs.html
@@ -1,4 +1,4 @@
-waker.rs - source
+waker.rs - source
1
2
@@ -280,6 +280,12 @@
278
279
280
+281
+282
+283
+284
+285
+286
//! Waking mechanism for threads blocked on channel operations.
use std::ptr;
@@ -359,26 +365,32 @@
/// Attempts to find another thread's entry, select the operation, and wake it up.
#[inline]
pub(crate) fn try_select(&mut self) -> Option<Entry> {
- self.selectors
- .iter()
- .position(|selector| {
- // Does the entry belong to a different thread?
- selector.cx.thread_id() != current_thread_id()
- && selector // Try selecting this operation.
- .cx
- .try_select(Selected::Operation(selector.oper))
- .is_ok()
- && {
- // Provide the packet.
- selector.cx.store_packet(selector.packet);
- // Wake the thread up.
- selector.cx.unpark();
- true
- }
- })
- // Remove the entry from the queue to keep it clean and improve
- // performance.
- .map(|pos| self.selectors.remove(pos))
+ if self.selectors.is_empty() {
+ None
+ } else {
+ let thread_id = current_thread_id();
+
+ self.selectors
+ .iter()
+ .position(|selector| {
+ // Does the entry belong to a different thread?
+ selector.cx.thread_id() != thread_id
+ && selector // Try selecting this operation.
+ .cx
+ .try_select(Selected::Operation(selector.oper))
+ .is_ok()
+ && {
+ // Provide the packet.
+ selector.cx.store_packet(selector.packet);
+ // Wake the thread up.
+ selector.cx.unpark();
+ true
+ }
+ })
+ // Remove the entry from the queue to keep it clean and improve
+ // performance.
+ .map(|pos| self.selectors.remove(pos))
+ }
}
/// Returns `true` if there is an entry which can be selected by the current thread.
Version 0.5.4
Crate crossbeam_channel[−][src]
Expand description
Multi-producer multi-consumer channels for message passing.
+Crate crossbeam_channel
Version 0.5.4
Crate crossbeam_channel[−][src]
Expand description
Multi-producer multi-consumer channels for message passing.
This crate is an alternative to std::sync::mpsc
with more features and better performance.
Hello, world!
use crossbeam_channel::unbounded;
diff --git a/rustdoc/src/crossbeam_channel/channel.rs.html b/rustdoc/src/crossbeam_channel/channel.rs.html
index c2d53b5e..29441fe3 100644
--- a/rustdoc/src/crossbeam_channel/channel.rs.html
+++ b/rustdoc/src/crossbeam_channel/channel.rs.html
@@ -1,4 +1,4 @@
-channel.rs - source
+channel.rs - source
1
2
diff --git a/rustdoc/src/crossbeam_channel/context.rs.html b/rustdoc/src/crossbeam_channel/context.rs.html
index 5d280570..608dd2a3 100644
--- a/rustdoc/src/crossbeam_channel/context.rs.html
+++ b/rustdoc/src/crossbeam_channel/context.rs.html
@@ -1,4 +1,4 @@
-context.rs - source
+context.rs - source
1
2
diff --git a/rustdoc/src/crossbeam_channel/counter.rs.html b/rustdoc/src/crossbeam_channel/counter.rs.html
index 4e1f9c57..9c7f3b96 100644
--- a/rustdoc/src/crossbeam_channel/counter.rs.html
+++ b/rustdoc/src/crossbeam_channel/counter.rs.html
@@ -1,4 +1,4 @@
-counter.rs - source
+counter.rs - source
1
2
diff --git a/rustdoc/src/crossbeam_channel/err.rs.html b/rustdoc/src/crossbeam_channel/err.rs.html
index 0d36a2f7..4154c777 100644
--- a/rustdoc/src/crossbeam_channel/err.rs.html
+++ b/rustdoc/src/crossbeam_channel/err.rs.html
@@ -1,4 +1,4 @@
-err.rs - source
+err.rs - source
1
2
diff --git a/rustdoc/src/crossbeam_channel/flavors/array.rs.html b/rustdoc/src/crossbeam_channel/flavors/array.rs.html
index 8a0ba06f..974ab916 100644
--- a/rustdoc/src/crossbeam_channel/flavors/array.rs.html
+++ b/rustdoc/src/crossbeam_channel/flavors/array.rs.html
@@ -1,4 +1,4 @@
-array.rs - source
+array.rs - source
1
2
diff --git a/rustdoc/src/crossbeam_channel/flavors/at.rs.html b/rustdoc/src/crossbeam_channel/flavors/at.rs.html
index 91578874..bec6b53b 100644
--- a/rustdoc/src/crossbeam_channel/flavors/at.rs.html
+++ b/rustdoc/src/crossbeam_channel/flavors/at.rs.html
@@ -1,4 +1,4 @@
-at.rs - source
+at.rs - source
1
2
diff --git a/rustdoc/src/crossbeam_channel/flavors/list.rs.html b/rustdoc/src/crossbeam_channel/flavors/list.rs.html
index 75ca7d2d..15600ff4 100644
--- a/rustdoc/src/crossbeam_channel/flavors/list.rs.html
+++ b/rustdoc/src/crossbeam_channel/flavors/list.rs.html
@@ -1,4 +1,4 @@
-list.rs - source
+list.rs - source
1
2
diff --git a/rustdoc/src/crossbeam_channel/flavors/mod.rs.html b/rustdoc/src/crossbeam_channel/flavors/mod.rs.html
index 061ccb8c..e7df4711 100644
--- a/rustdoc/src/crossbeam_channel/flavors/mod.rs.html
+++ b/rustdoc/src/crossbeam_channel/flavors/mod.rs.html
@@ -1,4 +1,4 @@
-mod.rs - source
+mod.rs - source
1
2
diff --git a/rustdoc/src/crossbeam_channel/flavors/never.rs.html b/rustdoc/src/crossbeam_channel/flavors/never.rs.html
index c4f60dd0..8ac968b6 100644
--- a/rustdoc/src/crossbeam_channel/flavors/never.rs.html
+++ b/rustdoc/src/crossbeam_channel/flavors/never.rs.html
@@ -1,4 +1,4 @@
-never.rs - source
+never.rs - source
1
2
diff --git a/rustdoc/src/crossbeam_channel/flavors/tick.rs.html b/rustdoc/src/crossbeam_channel/flavors/tick.rs.html
index c8efbd9f..e4873a6e 100644
--- a/rustdoc/src/crossbeam_channel/flavors/tick.rs.html
+++ b/rustdoc/src/crossbeam_channel/flavors/tick.rs.html
@@ -1,4 +1,4 @@
-tick.rs - source
+tick.rs - source
1
2
diff --git a/rustdoc/src/crossbeam_channel/flavors/zero.rs.html b/rustdoc/src/crossbeam_channel/flavors/zero.rs.html
index 70f4eeb7..c12694b4 100644
--- a/rustdoc/src/crossbeam_channel/flavors/zero.rs.html
+++ b/rustdoc/src/crossbeam_channel/flavors/zero.rs.html
@@ -1,4 +1,4 @@
-zero.rs - source
+zero.rs - source
1
2
diff --git a/rustdoc/src/crossbeam_channel/lib.rs.html b/rustdoc/src/crossbeam_channel/lib.rs.html
index c6f4f56c..23db3323 100644
--- a/rustdoc/src/crossbeam_channel/lib.rs.html
+++ b/rustdoc/src/crossbeam_channel/lib.rs.html
@@ -1,4 +1,4 @@
-lib.rs - source
+lib.rs - source
1
2
diff --git a/rustdoc/src/crossbeam_channel/select.rs.html b/rustdoc/src/crossbeam_channel/select.rs.html
index 849e0adc..e1c7770d 100644
--- a/rustdoc/src/crossbeam_channel/select.rs.html
+++ b/rustdoc/src/crossbeam_channel/select.rs.html
@@ -1,4 +1,4 @@
-select.rs - source
+select.rs - source
1
2
diff --git a/rustdoc/src/crossbeam_channel/select_macro.rs.html b/rustdoc/src/crossbeam_channel/select_macro.rs.html
index bd85d71a..ecda11dc 100644
--- a/rustdoc/src/crossbeam_channel/select_macro.rs.html
+++ b/rustdoc/src/crossbeam_channel/select_macro.rs.html
@@ -1,4 +1,4 @@
-select_macro.rs - source
+select_macro.rs - source
1
2
diff --git a/rustdoc/src/crossbeam_channel/utils.rs.html b/rustdoc/src/crossbeam_channel/utils.rs.html
index 1d7f4bce..9896fa20 100644
--- a/rustdoc/src/crossbeam_channel/utils.rs.html
+++ b/rustdoc/src/crossbeam_channel/utils.rs.html
@@ -1,4 +1,4 @@
-utils.rs - source
+utils.rs - source
1
2
diff --git a/rustdoc/src/crossbeam_channel/waker.rs.html b/rustdoc/src/crossbeam_channel/waker.rs.html
index 9c7bcaa7..3382c5e2 100644
--- a/rustdoc/src/crossbeam_channel/waker.rs.html
+++ b/rustdoc/src/crossbeam_channel/waker.rs.html
@@ -1,4 +1,4 @@
-waker.rs - source
+waker.rs - source
1
2
@@ -280,6 +280,12 @@
278
279
280
+281
+282
+283
+284
+285
+286
//! Waking mechanism for threads blocked on channel operations.
use std::ptr;
@@ -359,26 +365,32 @@
/// Attempts to find another thread's entry, select the operation, and wake it up.
#[inline]
pub(crate) fn try_select(&mut self) -> Option<Entry> {
- self.selectors
- .iter()
- .position(|selector| {
- // Does the entry belong to a different thread?
- selector.cx.thread_id() != current_thread_id()
- && selector // Try selecting this operation.
- .cx
- .try_select(Selected::Operation(selector.oper))
- .is_ok()
- && {
- // Provide the packet.
- selector.cx.store_packet(selector.packet);
- // Wake the thread up.
- selector.cx.unpark();
- true
- }
- })
- // Remove the entry from the queue to keep it clean and improve
- // performance.
- .map(|pos| self.selectors.remove(pos))
+ if self.selectors.is_empty() {
+ None
+ } else {
+ let thread_id = current_thread_id();
+
+ self.selectors
+ .iter()
+ .position(|selector| {
+ // Does the entry belong to a different thread?
+ selector.cx.thread_id() != thread_id
+ && selector // Try selecting this operation.
+ .cx
+ .try_select(Selected::Operation(selector.oper))
+ .is_ok()
+ && {
+ // Provide the packet.
+ selector.cx.store_packet(selector.packet);
+ // Wake the thread up.
+ selector.cx.unpark();
+ true
+ }
+ })
+ // Remove the entry from the queue to keep it clean and improve
+ // performance.
+ .map(|pos| self.selectors.remove(pos))
+ }
}
/// Returns `true` if there is an entry which can be selected by the current thread.