template <typename T>

class AtomicOptional

Defined at line 25 of file ../../src/media/audio/services/mixer/common/atomic_optional.h

An atomic container for an optional value, where a value can be pushed to or popped from the

container atomically.

This essentially builds a single-producer multiple-consumer FIFO with a size of 1 under the hood.

Multiple threads are allowed to `pop` a value concurrently, although only one could successfully

retrieve the contained value. Only a single thread is allowed to `push` a value to be contained

at a time. Both operations are lock-free and wait-free, and do not incur any dynamic memory

allocations except for any caused by the destructor of the value type `T`.

Public Methods

void AtomicOptional<T> ()

Defined at line 27 of file ../../src/media/audio/services/mixer/common/atomic_optional.h

void AtomicOptional<T> (const AtomicOptional<T> & )

Defined at line 28 of file ../../src/media/audio/services/mixer/common/atomic_optional.h

AtomicOptional<T> & operator= (const AtomicOptional<T> & )

Defined at line 29 of file ../../src/media/audio/services/mixer/common/atomic_optional.h

void AtomicOptional<T> (AtomicOptional<T> && )

Defined at line 30 of file ../../src/media/audio/services/mixer/common/atomic_optional.h

AtomicOptional<T> & operator= (AtomicOptional<T> && )

Defined at line 31 of file ../../src/media/audio/services/mixer/common/atomic_optional.h

bool push (T value)

Pushes a new value to the container if the container is empty, and returns true. If the

container already had a value, immediately returns false without updating the value.

Note that this will cause the destructor of the value type `T` to be called if the push was

successful. Therefore, it is advisable to only call this method from a non real-time thread for

complex types.

This can only be called from a single thread.

Defined at line 41 of file ../../src/media/audio/services/mixer/common/atomic_optional.h

std::optional<T> pop ()

Pops the value if any, or returns `std::nullopt` if the container has no value.

This can be called from multiple threads.

Defined at line 58 of file ../../src/media/audio/services/mixer/common/atomic_optional.h