Expand description
Space can be used to track how much has been reserved of a (limited)
amount of space.
The idea is that the Space is decoupled from the actual storage space it
is meant to represent. (It can refer to persistent disk storage,
in-process memory, or any other sized storage).
§Usage
An application creates a Space object, passing into it the amount of
total space it can hold.
Once the Space object has been created (representing the total amount of
space), the application can reserve space from this pool using:
Space::reserve_blocking()will block the calling thread and wait for the requested amount of space to become available.Space::reserve_async()is similar toSpace::reserve_blocking, but is intended forasynccontexts.Space::try_reservewill immediately fail if the reservation request can not be fulfilled.Space::force_reservewill always immediately succeed (this will allow the used storage space to overflow).
All of the reservation functions return a SpaceToken instance, which
represents the allocated space. This is returned to the Space context
when the SpaceToken is dropped.
Structs§
- Reserve
Future - Space
- A representation of a limited storage space that can be reserved.
- Space
Token - Representation of space reserved from a
Spacecontext.