pub struct SyncStack(/* private fields */);Expand description
A stack of blocked threads.
Implementations§
Source§impl SyncStack
impl SyncStack
Sourcepub fn park<P>(&self) -> boolwhere
P: Park,
pub fn park<P>(&self) -> boolwhere
P: Park,
Attempts to block the current thread on the top of the SyncStack.
Returns true if this thread was blocked and then unblocked.
Note that the Park implementation used does not have to be the same for every
call to park; as such different thread implementations can all wait on the same
SyncStack.
use sync_stack::*;
static STACK: SyncStack = SyncStack::INIT;
std::thread::spawn(move || {
//This threads execution stops.
STACK.park::<Thread>();
println!("Ran Second");
});
println!("Ran First");
//The other thread resumes execution.
STACK.pop();Auto Trait Implementations§
impl !Freeze for SyncStack
impl RefUnwindSafe for SyncStack
impl Send for SyncStack
impl Sync for SyncStack
impl Unpin for SyncStack
impl !UnwindSafe for SyncStack
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more