Skip to main content

Module blocking

Module blocking 

Source
Expand description

A blocking facade over crate::Store, for synchronous callers with no async runtime.

Each Store owns one worker thread running a private single-threaded runtime; a call sends its work to that thread over a channel and waits for the reply. The calling thread never drives the runtime, so a call is safe from plain code, from inside someone else’s tokio runtime of either flavour (no block_on inside a runtime, which would panic or deadlock), and from many threads at once. Inside an async task it blocks that task’s thread for the duration of the call, as any blocking call does: prefer the async crate::Store there.

A call made from a worker thread of any blocking Store is refused with Error::Reentrant instead of waiting: the worker’s runtime has one thread, so it would wait on a reply only it could produce. No public API of this crate runs caller code on a worker today, so this guards an invariant rather than a path a caller can reach.

OpenDAL’s own blocking::Operator was evaluated and not used: it must be created inside a running tokio runtime, uses Handle::block_on (which panics when called from within a runtime), and would put OpenDAL types in our API.

Structs§

Store
A crate::Store for synchronous code. Same needs, same refusals, same atomic replace.