1/// Temporary data that gets initialized during a blocking operation, and is consumed by
2/// `read` or `write`.
3///
4/// Each field contains data associated with a specific channel flavor.
5#[derive(#[automatically_derived]
impl ::core::fmt::Debug for Token {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_struct_field3_finish(f, "Token",
"array", &self.array, "list", &self.list, "zero", &&self.zero)
}
}Debug, #[automatically_derived]
impl ::core::default::Default for Token {
#[inline]
fn default() -> Token {
Token {
array: ::core::default::Default::default(),
list: ::core::default::Default::default(),
zero: ::core::default::Default::default(),
}
}
}Default)]
6pub struct Token {
7pub(crate) array: super::array::ArrayToken,
8pub(crate) list: super::list::ListToken,
9#[allow(dead_code)]
10pub(crate) zero: super::zero::ZeroToken,
11}
1213/// Identifier associated with an operation by a specific thread on a specific channel.
14#[derive(#[automatically_derived]
impl ::core::fmt::Debug for Operation {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
::core::fmt::Formatter::debug_tuple_field1_finish(f, "Operation",
&&self.0)
}
}Debug, #[automatically_derived]
impl ::core::clone::Clone for Operation {
#[inline]
fn clone(&self) -> Operation {
let _: ::core::clone::AssertParamIsClone<usize>;
*self
}
}Clone, #[automatically_derived]
impl ::core::marker::Copy for Operation { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for Operation {
#[inline]
fn eq(&self, other: &Operation) -> bool { self.0 == other.0 }
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for Operation {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<usize>;
}
}Eq)]
15pub struct Operation(usize);
1617impl Operation {
18/// Creates an operation identifier from a mutable reference.
19 ///
20 /// This function essentially just turns the address of the reference into a number. The
21 /// reference should point to a variable that is specific to the thread and the operation,
22 /// and is alive for the entire duration of a blocking operation.
23#[inline]
24pub fn hook<T>(r: &mut T) -> Operation {
25let val = ras *mut T as usize;
26// Make sure that the pointer address doesn't equal the numerical representation of
27 // `Selected::{Waiting, Aborted, Disconnected}`.
28if !(val > 2) { ::core::panicking::panic("assertion failed: val > 2") };assert!(val > 2);
29Operation(val)
30 }
31}
3233/// Current state of a blocking operation.
34#[derive(#[automatically_derived]
impl ::core::fmt::Debug for Selected {
#[inline]
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match self {
Selected::Waiting =>
::core::fmt::Formatter::write_str(f, "Waiting"),
Selected::Aborted =>
::core::fmt::Formatter::write_str(f, "Aborted"),
Selected::Disconnected =>
::core::fmt::Formatter::write_str(f, "Disconnected"),
Selected::Operation(__self_0) =>
::core::fmt::Formatter::debug_tuple_field1_finish(f,
"Operation", &__self_0),
}
}
}Debug, #[automatically_derived]
impl ::core::clone::Clone for Selected {
#[inline]
fn clone(&self) -> Selected {
let _: ::core::clone::AssertParamIsClone<Operation>;
*self
}
}Clone, #[automatically_derived]
impl ::core::marker::Copy for Selected { }Copy, #[automatically_derived]
impl ::core::cmp::PartialEq for Selected {
#[inline]
fn eq(&self, other: &Selected) -> bool {
let __self_discr = ::core::intrinsics::discriminant_value(self);
let __arg1_discr = ::core::intrinsics::discriminant_value(other);
__self_discr == __arg1_discr &&
match (self, other) {
(Selected::Operation(__self_0), Selected::Operation(__arg1_0))
=> __self_0 == __arg1_0,
_ => true,
}
}
}PartialEq, #[automatically_derived]
impl ::core::cmp::Eq for Selected {
#[inline]
#[doc(hidden)]
#[coverage(off)]
fn assert_fields_are_eq(&self) {
let _: ::core::cmp::AssertParamIsEq<Operation>;
}
}Eq)]
35pub enum Selected {
36/// Still waiting for an operation.
37Waiting,
3839/// The attempt to block the current thread has been aborted.
40Aborted,
4142/// An operation became ready because a channel is disconnected.
43Disconnected,
4445/// An operation became ready because a message can be sent or received.
46Operation(Operation),
47}
4849impl From<usize> for Selected {
50#[inline]
51fn from(val: usize) -> Selected {
52match val {
530 => Selected::Waiting,
541 => Selected::Aborted,
552 => Selected::Disconnected,
56 oper => Selected::Operation(Operation(oper)),
57 }
58 }
59}
6061impl Into<usize> for Selected {
62#[inline]
63fn into(self) -> usize {
64match self {
65 Selected::Waiting => 0,
66 Selected::Aborted => 1,
67 Selected::Disconnected => 2,
68 Selected::Operation(Operation(val)) => val,
69 }
70 }
71}