pub struct SpawnedReader<R> {
inner: R,
handle: Handle,
}Expand description
An AsyncFileReader that performs I/O on a separate tokio runtime.
Tokio is a cooperative scheduler, and relies on tasks yielding in a timely manner to service IO. Therefore, running IO and CPU-bound tasks, such as avro decoding, on the same tokio runtime can lead to degraded throughput, dropped connections and other issues. For more information see here.
This wrapper spawns each operation of the inner reader onto the provided
runtime [Handle], so that the runtime driving the avro decoding does not
also drive the I/O.
The inner reader must be Clone (typically an Arc’d handle to some
shared resource) as each spawned task requires a 'static copy of it.
Fields§
§inner: R§handle: HandleImplementations§
Source§impl<R> SpawnedReader<R>
impl<R> SpawnedReader<R>
Sourcepub fn new(inner: R, handle: Handle) -> Self
pub fn new(inner: R, handle: Handle) -> Self
Creates a new SpawnedReader that performs the I/O of inner on handle
Sourcepub fn into_inner(self) -> R
pub fn into_inner(self) -> R
Returns the inner reader
Trait Implementations§
Source§impl<R> AsyncFileReader for SpawnedReader<R>
impl<R> AsyncFileReader for SpawnedReader<R>
Source§impl<R: Clone> Clone for SpawnedReader<R>
impl<R: Clone> Clone for SpawnedReader<R>
Source§fn clone(&self) -> SpawnedReader<R>
fn clone(&self) -> SpawnedReader<R>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl<R> Freeze for SpawnedReader<R>where
R: Freeze,
impl<R> RefUnwindSafe for SpawnedReader<R>where
R: RefUnwindSafe,
impl<R> Send for SpawnedReader<R>where
R: Send,
impl<R> Sync for SpawnedReader<R>where
R: Sync,
impl<R> Unpin for SpawnedReader<R>where
R: Unpin,
impl<R> UnsafeUnpin for SpawnedReader<R>where
R: UnsafeUnpin,
impl<R> UnwindSafe for SpawnedReader<R>where
R: UnwindSafe,
Blanket Implementations§
impl<T> Allocation for T
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
Mutably borrows from an owned value. Read more