Struct Proactor
pub struct Proactor { /* private fields */ }Expand description
Low-level actions of completion-based IO. It owns the operations to keep the driver safe.
Implementations§
§impl Proactor
impl Proactor
pub fn builder() -> ProactorBuilder
pub fn builder() -> ProactorBuilder
Create ProactorBuilder to config the proactor.
pub fn default_extra(&self) -> Extra
pub fn default_extra(&self) -> Extra
Get a default Extra for underlying driver.
pub fn driver_type(&self) -> DriverType
pub fn driver_type(&self) -> DriverType
The current driver type.
pub fn attach(&mut self, fd: i32) -> Result<(), Error>
pub fn attach(&mut self, fd: i32) -> Result<(), Error>
Attach an fd to the driver.
§Platform specific
- IOCP: it will be attached to the completion port. An fd could only be
attached to one driver, and could only be attached once, even if you
try_cloneit. - io-uring & polling: it will do nothing but return
Ok(()).
pub fn cancel<T>(&mut self, key: Key<T>) -> Option<BufResult<usize, T>>where
T: OpCode,
pub fn cancel<T>(&mut self, key: Key<T>) -> Option<BufResult<usize, T>>where
T: OpCode,
Cancel an operation with the pushed Key.
Returns the result if the key is unique and the operation is completed.
The cancellation is not reliable. The underlying operation may continue,
but just don’t return from Proactor::poll.
pub fn cancel_token(&mut self, token: Cancel) -> bool
pub fn cancel_token(&mut self, token: Cancel) -> bool
Cancel an operation with a Cancel token.
Returns if a cancellation has been issued.
The cancellation is not reliable. The underlying operation may continue,
but just don’t return from Proactor::pop. This will do nothing if
the operation has already been completed or cancelled before.
pub fn register_cancel<T>(&mut self, key: &Key<T>) -> Cancelwhere
T: OpCode,
pub fn register_cancel<T>(&mut self, key: &Key<T>) -> Cancelwhere
T: OpCode,
Create a Cancel that can be used to cancel the operation even
without the key.
This acts like a weak reference to the Key, but can only be used to
cancel the operation with Proactor::cancel_token. Extra copy of
Key may cause Proactor::pop to panic while keys registered
as Cancel will be properly handled. So this is useful in cases
where you’re not sure if the operation will be cancelled.
pub fn push<T>(&mut self, op: T) -> PushEntry<Key<T>, BufResult<usize, T>>where
T: OpCode + 'static,
pub fn push<T>(&mut self, op: T) -> PushEntry<Key<T>, BufResult<usize, T>>where
T: OpCode + 'static,
Push an operation into the driver, and return the unique key Key,
associated with it.
pub fn push_with_extra<T>(
&mut self,
op: T,
extra: Extra,
) -> PushEntry<Key<T>, BufResult<usize, T>>where
T: OpCode + 'static,
pub fn push_with_extra<T>(
&mut self,
op: T,
extra: Extra,
) -> PushEntry<Key<T>, BufResult<usize, T>>where
T: OpCode + 'static,
pub fn poll(&mut self, timeout: Option<Duration>) -> Result<(), Error>
pub fn poll(&mut self, timeout: Option<Duration>) -> Result<(), Error>
Poll the driver and get completed entries.
You need to call Proactor::pop to get the pushed
operations.
pub fn pop_with_extra<T>(
&mut self,
key: Key<T>,
) -> PushEntry<Key<T>, (BufResult<usize, T>, Extra)>
pub fn pop_with_extra<T>( &mut self, key: Key<T>, ) -> PushEntry<Key<T>, (BufResult<usize, T>, Extra)>
pub fn pop_multishot<T>(
&mut self,
key: &Key<T>,
) -> Option<BufResult<usize, Extra>>
pub fn pop_multishot<T>( &mut self, key: &Key<T>, ) -> Option<BufResult<usize, Extra>>
Get one completion entry for a multishot operation. If it returns
None, the user should call Proactor::pop_with_extra to get the
final result of the operation.
pub fn update_waker<T>(&mut self, op: &Key<T>, waker: &Waker)
pub fn update_waker<T>(&mut self, op: &Key<T>, waker: &Waker)
Update the waker of the specified op.
pub fn create_buffer_pool(
&mut self,
buffer_len: u16,
buffer_size: usize,
) -> Result<BufferPool, Error>
pub fn create_buffer_pool( &mut self, buffer_len: u16, buffer_size: usize, ) -> Result<BufferPool, Error>
Create buffer pool with given buffer_size and buffer_len
§Notes
If buffer_len is not a power of 2, it will be rounded up with
u16::next_power_of_two.
pub unsafe fn release_buffer_pool(
&mut self,
buffer_pool: BufferPool,
) -> Result<(), Error>
pub unsafe fn release_buffer_pool( &mut self, buffer_pool: BufferPool, ) -> Result<(), Error>
Release the buffer pool
§Safety
Caller must make sure to release the buffer pool with the correct driver, i.e., the one they created the buffer pool with.
pub fn register_files(&self, fds: &[i32]) -> Result<(), Error>
pub fn register_files(&self, fds: &[i32]) -> Result<(), Error>
Register file descriptors for fixed-file operations with io_uring.
This only works on io_uring driver. It will return an Unsupported
error on other drivers.
pub fn unregister_files(&self) -> Result<(), Error>
pub fn unregister_files(&self) -> Result<(), Error>
Unregister previously registered file descriptors.
This only works on io_uring driver. It will return an Unsupported
error on other drivers.
pub fn register_personality(&self) -> Result<u16, Error>
pub fn register_personality(&self) -> Result<u16, Error>
Register a new personality in io-uring driver.
Returns the personality id, which can be used with
Extra::set_personality to set the personality for an operation.
This only works on io_uring driver. It will return an Unsupported
error on other drivers. See Submitter::register_personality for
more.
pub fn unregister_personality(&self, personality: u16) -> Result<(), Error>
pub fn unregister_personality(&self, personality: u16) -> Result<(), Error>
Unregister the given personality in io-uring driver.
This only works on io_uring driver. It will return an Unsupported
error on other drivers. See Submitter::unregister_personality for
more.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Proactor
impl !RefUnwindSafe for Proactor
impl !Send for Proactor
impl !Sync for Proactor
impl Unpin for Proactor
impl UnsafeUnpin for Proactor
impl !UnwindSafe for Proactor
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more