class AllocatorReservation

Defined at line 32 of file ../../src/storage/minfs/allocator/allocator_reservation.h

This class represents a reservation from an Allocator to save a particular number of reserved

elements for later allocation. Allocation for reserved elements must be done through the

AllocatorReservation class.

This class is thread-compatible.

This class is not assignable, copyable, or moveable.

Public Methods

void AllocatorReservation (Allocator * allocator)

Defined at line 15 of file ../../src/storage/minfs/allocator/allocator_reservation.cc

void ~AllocatorReservation ()

Defined at line 16 of file ../../src/storage/minfs/allocator/allocator_reservation.cc

zx::result<> Reserve (PendingWork * transaction, size_t reserved)

Returns |ZX_OK| when |allocator| reserves |reserved| elements and |this| is successfully

initialized. Returns an error if not enough elements are available for reservation,

or there was previous reservation.

Defined at line 18 of file ../../src/storage/minfs/allocator/allocator_reservation.cc

zx::result<> ExtendReservation (PendingWork * transaction, size_t reserved)

Extends reservation by |reserved| number of elements.

Returns an error if not enough elements are available for reservation.

Defined at line 29 of file ../../src/storage/minfs/allocator/allocator_reservation.cc

void AllocatorReservation (const AllocatorReservation & )

Not copyable or movable.

Defined at line 37 of file ../../src/storage/minfs/allocator/allocator_reservation.h

size_t Allocate ()

Allocate a new item in allocator_. Return the index of the newly allocated item.

Defined at line 37 of file ../../src/storage/minfs/allocator/allocator_reservation.cc

AllocatorReservation & operator= (const AllocatorReservation & )

Defined at line 38 of file ../../src/storage/minfs/allocator/allocator_reservation.h

void Deallocate (size_t element)

Deallocate a new item from allocate_.

Defined at line 43 of file ../../src/storage/minfs/allocator/allocator_reservation.cc

void Cancel ()

Unreserve all currently reserved items.

Defined at line 55 of file ../../src/storage/minfs/allocator/allocator_reservation.cc

size_t Swap (size_t old_index)

Swap the element currently allocated at |old_index| for a new index.

If |old_index| is 0, a new block will still be allocated, but no blocks will be de-allocated.

The swap will not be persisted until a call to Commit is made.

Defined at line 46 of file ../../src/storage/minfs/allocator/allocator_reservation.cc

PendingAllocations & GetPendingAllocations (Allocator * allocator)

Returns the pending allocations. Only Allocator should manipulate it.

Defined at line 62 of file ../../src/storage/minfs/allocator/allocator_reservation.cc

PendingDeallocations & GetPendingDeallocations (Allocator * allocator)

Returns the pending deallocations. Only Allocator should manipulate it.

Defined at line 69 of file ../../src/storage/minfs/allocator/allocator_reservation.cc

std::unique_ptr<PendingDeallocations> TakePendingDeallocations ()

Defined at line 75 of file ../../src/storage/minfs/allocator/allocator_reservation.h

void Commit (PendingWork * transaction)

Commit all pending changes, which means all bitmaps are updated (via the transaction). You most

likely don't need to call this because it is called in Minfs::CommitTransaction.

Defined at line 76 of file ../../src/storage/minfs/allocator/allocator_reservation.cc

size_t GetReserved ()

Defined at line 83 of file ../../src/storage/minfs/allocator/allocator_reservation.h