[][src]Crate blocking_permit

This crate provides:

  • A specialized, custom thread pool, DispatchPool, for offloading blocking or otherwise long running operations from a main or reactor thread(s). Once registered, it is used via dispatch_rx() (to await a return value) or dispatch() for background tasks (fire and forget).

  • A BlockingPermit, obtained via blocking_permit_future() for limiting the number of concurrent blocking operations via a re-exported Semaphore type selected by one of the (non-default) features futures-intrusive, or tokio-semaphore (or tokio-omnibus).

Macros

dispatch_or_permit

Attempt to dispatch a blocking operation, or otherwise obtain a permit and run on thread, returning the result of the closure.

Structs

BlockingPermit

A scoped permit for blocking operations. When dropped (out of scope or manually), the permit is released.

BlockingPermitFuture

A future which resolves to a BlockingPermit.

Canceled

Error type returned as output from the BlockingPermitFuture or Dispatched futures if they are canceled.

DispatchPool

A specialized thread pool and queue for dispatching blocking (synchronous, long running) operations.

DispatchPoolBuilder

A builder for DispatchPool supporting an extenstive set of configuration options.

Dispatched

A future type created by dispatch_rx.

SyncBlockingPermitFuture

A Sync wrapper available via BlockingPermitFuture::make_sync.

Enums

DispatchRx

Value returned by dispatch_rx.

Traits

Semaphorish

Extension trait for uniform construction of the re-exported Semaphore types.

Functions

blocking_permit_future

Request a permit to perform a blocking operation on the current thread.

deregister_dispatch_pool

Deregister and return any DispatchPool on the current thread.

dispatch

Dispatch a blocking operation closure to a pool, if registered.

dispatch_rx

Dispatch a blocking operation closure to a registered pool, returning a future for awaiting the result.

is_dispatch_pool_registered

Return true if a DispatchPool is registered to the current thread.

register_dispatch_pool

Register a DispatchPool on the calling thread.

Type Definitions

Semaphore

An async-aware semaphore for constraining the number of concurrent blocking operations.