Struct SetReadiness

Source
pub struct SetReadiness { /* private fields */ }
Expand description

Updates the readiness state of the associated Registration.

See Registration for more documentation on using SetReadiness and Poll for high level polling documentation.

Implementations§

Source§

impl SetReadiness

Source

pub fn readiness(&self) -> Ready

Returns the registration’s current readiness.

§Note

There is no guarantee that readiness establishes any sort of memory ordering. Any concurrent data access must be synchronized using another strategy.

§Examples
use futures_net::driver::sys::Registration;
use futures_net::driver::sys::event::Ready;

let (registration, set_readiness) = Registration::new2();

assert!(set_readiness.readiness().is_empty());

set_readiness.set_readiness(Ready::readable())?;
assert!(set_readiness.readiness().is_readable());
Source

pub fn set_readiness(&self, ready: Ready) -> Result<()>

Set the registration’s readiness

If the associated Registration is registered with a Poll instance and has requested readiness events that include ready, then a future call to Poll::poll will receive a readiness event representing the readiness state change.

§Note

There is no guarantee that readiness establishes any sort of memory ordering. Any concurrent data access must be synchronized using another strategy.

There is also no guarantee as to when the readiness event will be delivered to poll. A best attempt will be made to make the delivery in a “timely” fashion. For example, the following is not guaranteed to work:

use futures_net::driver::sys::{Poll, Registration, Token};
use futures_net::driver::sys::event::{Events, Ready, PollOpt};

let poll = Poll::new()?;
let (registration, set_readiness) = Registration::new2();

poll.register(&registration,
              Token(0),
              Ready::readable(),
              PollOpt::edge())?;

// Set the readiness, then immediately poll to try to get the readiness
// event
set_readiness.set_readiness(Ready::readable())?;

let mut events = Events::with_capacity(1024);
poll.poll(&mut events, None)?;

// There is NO guarantee that the following will work. It is possible
// that the readiness event will be delivered at a later time.
let event = events.get(0).unwrap();
assert_eq!(event.token(), Token(0));
assert!(event.readiness().is_readable());
§Examples

A simple example, for a more elaborate example, see the Evented documentation.

use futures_net::driver::sys::Registration;
use futures_net::driver::sys::event::Ready;

let (registration, set_readiness) = Registration::new2();

assert!(set_readiness.readiness().is_empty());

set_readiness.set_readiness(Ready::readable())?;
assert!(set_readiness.readiness().is_readable());

Trait Implementations§

Source§

impl Clone for SetReadiness

Source§

fn clone(&self) -> SetReadiness

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SetReadiness

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Send for SetReadiness

Source§

impl Sync for SetReadiness

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.