Struct miow::iocp::CompletionPort

source ·
pub struct CompletionPort { /* private fields */ }
Expand description

A handle to an Windows I/O Completion Port.

Implementations§

source§

impl CompletionPort

source

pub fn new(threads: u32) -> Result<CompletionPort>

Creates a new I/O completion port with the specified concurrency value.

The number of threads given corresponds to the level of concurrency allowed for threads associated with this port. Consult the Windows documentation for more information about this value.

source

pub fn add_handle<T: AsRawHandle + ?Sized>( &self, token: usize, t: &T ) -> Result<()>

Associates a new HANDLE to this I/O completion port.

This function will associate the given handle to this port with the given token to be returned in status messages whenever it receives a notification.

Any object which is convertible to a HANDLE via the AsRawHandle trait can be provided to this function, such as std::fs::File and friends.

source

pub fn add_socket<T: AsRawSocket + ?Sized>( &self, token: usize, t: &T ) -> Result<()>

Associates a new SOCKET to this I/O completion port.

This function will associate the given socket to this port with the given token to be returned in status messages whenever it receives a notification.

Any object which is convertible to a SOCKET via the AsRawSocket trait can be provided to this function, such as std::net::TcpStream and friends.

source

pub fn get(&self, timeout: Option<Duration>) -> Result<CompletionStatus>

Dequeue a completion status from this I/O completion port.

This function will associate the calling thread with this completion port and then wait for a status message to become available. The precise semantics on when this function returns depends on the concurrency value specified when the port was created.

A timeout can optionally be specified to this function. If None is provided this function will not time out, and otherwise it will time out after the specified duration has passed.

On success this will return the status message which was dequeued from this completion port.

source

pub fn get_many<'a>( &self, list: &'a mut [CompletionStatus], timeout: Option<Duration> ) -> Result<&'a mut [CompletionStatus]>

Dequeues a number of completion statuses from this I/O completion port.

This function is the same as get except that it may return more than one status. A buffer of “zero” statuses is provided (the contents are not read) and then on success this function will return a sub-slice of statuses which represent those which were dequeued from this port. This function does not wait to fill up the entire list of statuses provided.

Like with get, a timeout may be specified for this operation.

source

pub fn post(&self, status: CompletionStatus) -> Result<()>

Posts a new completion status onto this I/O completion port.

This function will post the given status, with custom parameters, to the port. Threads blocked in get or get_many will eventually receive this status.

Trait Implementations§

source§

impl AsRawHandle for CompletionPort

source§

fn as_raw_handle(&self) -> RawHandle

Extracts the raw handle. Read more
source§

impl Debug for CompletionPort

source§

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

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

impl FromRawHandle for CompletionPort

source§

unsafe fn from_raw_handle(handle: RawHandle) -> CompletionPort

Constructs a new I/O object from the specified raw handle. Read more
source§

impl IntoRawHandle for CompletionPort

source§

fn into_raw_handle(self) -> RawHandle

Consumes this object, returning the raw underlying handle. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.