Library Moduleordo-one.package-concurrency-helpers 4.0.3PackageConcurrencyHelpers
PackageConcurrencyHelpers
import PackageConcurrencyHelpers
Module information
- Declarations
- 30
- Symbols
- 35
Uncategorized
Protocols
protocol Lockable
Protocol any lock can implement.
Types
class Lock
class Protected<T>
Thread safe access to simple variable protected by lock
class Spinlock
Lock to protect very short critical sections.
class UnsafeMutableTransferBox<Wrapped>
UnsafeMutableTransferBox
can be used to make non-Sendable
valuesSendable
and mutable. It can be used to capture local mutable values in a@Sendable
closure and mutate them from within the closure. As the name implies, the usage of this is unsafe because it disables the sendable checking of the compiler and does not add any synchronisation.struct UnsafeTransfer<Wrapped>
UnsafeTransfer
can be used to make non-Sendable
valuesSendable
. As the name implies, the usage of this is unsafe because it disables the sendable checking of the compiler. It can be used similar to@unsafe Sendable
but for values instead of types.
Globals
func forBlockingFunc<T>(queue: DispatchQueue, body: @escaping () -> T
) async -> T This function is a helper for calling blocking function from Task and properly suspend the Task while such call take place. The blocking function call happens in global dispatch queue and when it’s done calls continuation to resume suspended Task.
func runSync<T>(priority: TaskPriority?, @escaping () async throws -> T
) throws -> T Runs throwing async closure and waits for its result (incl. rethrowing exception) in non-async code.
func runSync<T>(priority: TaskPriority?, @escaping () async -> T
) -> T Runs async closure and waits for its result in non-async code.
func yieldWithBackPressure<Message>(message: Message, to: AsyncStream<Message>.Continuation
) async -> Bool Yields the
message
to the AsyncStreamcontinuation
with back pressure logic.