|
CeresEngine 0.2.0
A game development framework
|
The coroutine channel is a helper utility class that allows to implement easy object passing between coroutines. More...
#include <CeresEngine/Foundation/Channel.hpp>
Classes | |
| class | LinkedList |
| Minimal linked list without node allocation. More... | |
| class | Reader |
Awaitable reader for Channel More... | |
| class | Writer |
Awaitable writer for channel More... | |
Public Types | |
| using | Pointer = T * |
A pointer to T | |
| using | Reference = T & |
A reference of T | |
| using | Mutex = Lockable |
| The mutex type used to lock the channel. | |
Public Member Functions | |
| Channel ()=default | |
| Create a new channel. | |
| Channel (const Channel &)=delete | |
| Deleted copy constructor. | |
| Channel (Channel &&)=delete | |
| Deleted copy assignment operator. | |
| Channel & | operator= (const Channel &)=delete |
| Deleted move constructor. | |
| Channel & | operator= (Channel &&)=delete |
| Deleted move assignment operator. | |
| ~Channel () noexcept | |
| Destroys the channel. | |
| Writer | write (T value) noexcept |
Writes a value to the channel. | |
| Reader | read () noexcept |
Reads a value from the channel. | |
Private Types | |
| using | CoroutineHandle = typename std::coroutine_handle< void > |
| A type-alias to the coroutine handle used by channels. | |
Static Private Member Functions | |
| static constexpr void * | poison () noexcept |
Private Attributes | |
| Mutex | mutex |
| The mutex that synchronizes access to the channel. | |
| LinkedList< Reader > | readers |
A LinkedList of Readers. | |
| LinkedList< Writer > | writers |
A LinkedList of Writers. | |
The coroutine channel is a helper utility class that allows to implement easy object passing between coroutines.
An object written by a Writer will be received by a Reader. The Writer coroutine will resume after the `Reader“ awaits for another object.
| T | the type of object to be passed through the channel |
| Lockable | a lockable type used to synchronize the channel. By default this is NullLockable which does no locking. If the channel is being used across different threads, you must use a real lock like Mutex. |
|
private |
A type-alias to the coroutine handle used by channels.
| using CeresEngine::Channel< T, Lockable >::Mutex = Lockable |
The mutex type used to lock the channel.
| using CeresEngine::Channel< T, Lockable >::Pointer = T* |
A pointer to T
| using CeresEngine::Channel< T, Lockable >::Reference = T& |
A reference of T
|
default |
Create a new channel.
Deleted copy constructor.
Deleted copy assignment operator.
|
noexcept |
Destroys the channel.
|
delete |
Deleted move assignment operator.
|
delete |
Deleted move constructor.
|
inlinestaticconstexprprivatenoexcept |
|
inlinenoexcept |
Reads a value from the channel.
Reader object
|
inlinenoexcept |
Writes a value to the channel.
| value | The value to write to the channel |
Writer object
|
private |
The mutex that synchronizes access to the channel.
|
private |
A LinkedList of Readers.
|
private |
A LinkedList of Writers.