Struct: TReceiverChannel
template <typename T>
struct TReceiverChannel;
SPMC (single-prodicer, multiple-consumer) receiver channel.
See TSenderChannel.
Example
auto Sender = TSenderChannel<int>();
auto Receiver = Sender.Receiver(1);
Sender.Send(42);
while (const auto Value = Receiver.Receive())
{
UE_LOG(LogTemp, Warning, TEXT("Received value: %i"), Value);
}
Methods
-
Clearpublic: void Clear();
Clears internal queue.
User would rather want to read and conume stored messages but sometimes user might have valid reasons to discard all messages without reading them.
-
IsEmptypublic: bool IsEmpty() const;
Checks if there are incoming messages in queue.
-
Receivepublic: TOptional<T> Receive();
Consumes and returns one message from internal queue.
Example
auto Sender = TSenderChannel<int>(); auto Receiver = Sender.Receiver(1); Sender.Send(42); while (const auto Value = Receiver.Receive()) { UE_LOG(LogTemp, Warning, TEXT("Received value: %i"), Value); } -
Unbindpublic: void Unbind();
Unbind from sender.
This forcefully unbinds reciever from sender and clears internal queue, though user do not have to call this method when its lifetime ends - receivers unbind themselves as soon as they get destroyed. This method exists only in case user would want to stop receiving further messages on demand, useful in more advanced scenarios.
Documentation built with Unreal-Doc v1.0.8 tool by PsichiX