Classes
The following classes are available globally.
-
A generic class that protects a resource of type
T
with aLock
.The user of a
See moreLockedResource
accesses the resource via a read or write function. The resource itself is available only within the scope of the passed-in function, during which time the appropriate lock is guaranteed to be held.Declaration
Swift
open class LockedResource<T>
-
Registry
is a generic class designed to keep track of items (of typeT
) in a thread-safe way.The lifetime of an item in the registry is determined by the
Receipt
that was returned when the item was registered.You must maintain at least one strong reference to the returned
See moreReceipt
for the duration of the time that you want the item it represents to remain registered. Once theReceipt
deallocates, the associated item is removed from the registry.Declaration
Swift
public class Registry<T>
-
ReadWriteCoordinator
instances can be used to coordinate access to a mutable resource shared across multiple threads.You can think of the
ReadWriteCoordinator
as a read/write lock having the following properties:The read lock allows any number of readers to execute concurrently.
The write lock allows one and only one writer to execute at a time.
As long as there is at least one reader executing, the write lock cannot be acquired.
As long as the write lock is held, no readers can execute.
Declaration
Swift
public final class ReadWriteCoordinator