Skip to main content

Signalable

Trait Signalable 

Source
pub trait Signalable: AsHandle { }
Expand description

An object signal_object_and_wait can signal: an event, a semaphore or a mutex.

What a type implementing this promises is that signalling its handle is something the call can do, so a handle that cannot signal is refused when it is passed, not when the call fails. The wait-only handle (WaitOnlyEvent) does not implement it, and the compiler says so:

ⓘ
use win_sync_sys::{Alertable, Event, ResetMode, signal_object_and_wait};

let ping = Event::new(ResetMode::Auto, false)?;
let waiter = ping.try_clone_wait_only()?;
let pong = Event::new(ResetMode::Auto, true)?;
// A wait-only handle cannot be signalled.
signal_object_and_wait(&waiter, &pong, None, Alertable::No)?;

It is not sealed: a handle that implements it and cannot in fact be signalled gets the error from the call, not undefined behaviour.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T: Signalable + ?Sized> Signalable for &T

Implementors§