[−][src]Module thread_io::read
This module contains functions for reading in a background thread.
- The simplest to use is the
reader
function. It accepts anyio::Read
instance that implementsSend
. - The
reader_init
function handles cases where the wrapped reader cannot be sent safely across the thread boundary by providing a closure for initializing the reader in the background thread.
Error handling
io::Error
s occuring during reading in the background are returned by theread
method of the reader in the main thread as expected, but with a delay of at east one call.- Reading errors cause the background reader to stop, except for errors
of kind
io::ErrorKind::Interrupted
. In this case reading continues in background, allowing the user to resume reading after the error occurred. - The
func
closure running in the main thread allows returning errors of any type. If a reading error happens around the same time in the background thread and does not reach the main thread due to the reporting delay, it will be discarded and the error fromfunc
returned instead. - panics in the background reader are correctly forwarded to the main
thread, but are also given lower priority if an error is returned from
func
.
Structs
Reader | The reader in the main thread |
Functions
reader | Sends |
reader_init | Like |