pub struct Proactor { /* private fields */ }Expand description
Low-level actions of completion-based IO. It owns the operations to keep the driver safe.
Implementations§
Source§impl Proactor
impl Proactor
Sourcepub fn builder() -> ProactorBuilder
pub fn builder() -> ProactorBuilder
Create ProactorBuilder to config the proactor.
Sourcepub fn default_extra(&self) -> Extra
pub fn default_extra(&self) -> Extra
Get a default Extra for underlying driver.
Sourcepub fn driver_type(&self) -> DriverType
pub fn driver_type(&self) -> DriverType
The current driver type.
Sourcepub fn attach(&mut self, fd: RawFd) -> Result<()>
pub fn attach(&mut self, fd: RawFd) -> Result<()>
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(()).
Sourcepub fn cancel<T: OpCode>(&mut self, key: Key<T>) -> Option<BufResult<usize, T>>
pub fn cancel<T: OpCode>(&mut self, key: Key<T>) -> Option<BufResult<usize, T>>
Cancel an operation with the pushed Key.
The cancellation is not reliable. The underlying operation may continue,
but just don’t return from Proactor::poll.
Sourcepub fn push<T: OpCode + 'static>(
&mut self,
op: T,
) -> PushEntry<Key<T>, BufResult<usize, T>>
pub fn push<T: OpCode + 'static>( &mut self, op: T, ) -> PushEntry<Key<T>, BufResult<usize, T>>
Push an operation into the driver, and return the unique key Key,
associated with it.
Sourcepub fn push_with_extra<T: OpCode + 'static>(
&mut self,
op: T,
extra: Extra,
) -> PushEntry<Key<T>, BufResult<usize, T>>
pub fn push_with_extra<T: OpCode + 'static>( &mut self, op: T, extra: Extra, ) -> PushEntry<Key<T>, BufResult<usize, T>>
Sourcepub fn poll(&mut self, timeout: Option<Duration>) -> Result<()>
pub fn poll(&mut self, timeout: Option<Duration>) -> Result<()>
Poll the driver and get completed entries.
You need to call Proactor::pop to get the pushed
operations.
Sourcepub fn pop<T>(&mut self, key: Key<T>) -> PushEntry<Key<T>, BufResult<usize, T>>
pub fn pop<T>(&mut self, key: Key<T>) -> PushEntry<Key<T>, BufResult<usize, T>>
Get the pushed operations from the completion entries.
§Panics
This function will panic if the requested operation has not been completed.
Sourcepub 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)>
Sourcepub fn update_waker<T>(&mut self, op: &mut Key<T>, waker: &Waker)
pub fn update_waker<T>(&mut self, op: &mut Key<T>, waker: &Waker)
Update the waker of the specified op.
Sourcepub fn create_buffer_pool(
&mut self,
buffer_len: u16,
buffer_size: usize,
) -> Result<BufferPool>
pub fn create_buffer_pool( &mut self, buffer_len: u16, buffer_size: usize, ) -> Result<BufferPool>
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.
Sourcepub unsafe fn release_buffer_pool(
&mut self,
buffer_pool: BufferPool,
) -> Result<()>
pub unsafe fn release_buffer_pool( &mut self, buffer_pool: BufferPool, ) -> Result<()>
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.
Sourcepub fn register_personality(&self) -> Result<u16>
pub fn register_personality(&self) -> Result<u16>
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.
Sourcepub fn unregister_personality(&self, personality: u16) -> Result<()>
pub fn unregister_personality(&self, personality: u16) -> Result<()>
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.