Class RandomAccessAsyncStorage

Class Documentation

class RandomAccessAsyncStorage

TODO.

Public Types

enum [anonymous]

Values:

enumerator kInvalidOffset

Public Functions

RandomAccessAsyncStorage(stream::RandomAccessStorage *storage)

RandomAccessAsyncSerializer (ctor)

Parameters

storage -- Pointer to Storage representing a valid RandomAccessStorage instance. This property is not checked internally (other than by assert that is only active in Debug builds) and if the Storage provided is not of type RandomAccessStorage, the behavior is undefined.

~RandomAccessAsyncStorage()
std::unique_ptr<RandomAccessSerializer, UnlockDeleter> GetRandomSerializerAndLock()

Provides random access serializer for the underlaying storage @detail Locks access to underlying storage to limit access to only the returned serializer. Use only if the required storage size is unknown or difficult to calculate. No other thread is allowed to use the storage till returned serializer is alive Hard (write) lock is performed on the RWLock for the lifetime of the unique ptr returned by this function. NOTE: Obtaining more than one serializer in the same thread through GetRandomSerializerAndLock will cause deadlock.

std::unique_ptr<MemoryBackedSerializer, UnlockDeleter> GetSerializerForReservedSpace(size_t size, uint64_t *absoluteOffset = nullptr)

Provides memory backed serializer for the reserved space.

Parameters
  • size -- Size of reserved space on the storage

  • absoluteOffset -- Pointer to variable that will receive absolute offset of reserved space @detail Reserves the space on the underlying storage for random access serializer object returned by this function. It is guaranteed that the returned serializer will remain valid till it is destroyed. Altough this function does not perform storage-lock for the full lifetime of the returned serializer it is suggested to limit it to the minumum. This function may perform full storage lock in case there is not enough space on current storage. In such case it must wait for any other serializer obtained through this object to be destroyed. Soft (read) lock is performed on the RWLock for the lifetime of the unique ptr returned by this function NOTE: Obtaining more than one serializer in the same thread through GetSerializerForReservedSpace may result in deadlock, unless the previous one is released.

std::unique_ptr<MemoryBackedSerializer, UnlockDeleter> GetSerializerForExistingSpace(uint64_t absoluteOffset, size_t size)

Provides memory backed serializer for the existing space in the storage.

Parameters
  • absoluteOffset -- Absolute offset of requested space

  • size -- Size of requested space on the storage @detail Same policy as in @GetSerializerForReservedSpace NOTE: Obtaining a serializer in the same thread through GetSerializerForReservedSpace may result in deadlock, if a serializer obtained through this function is still alive. It is allowed though to obtain one through this function AFTER obtaining one through GetSerializerForReservedSpace.