async_patterns:: Receiver
#include <receiver.h>
A |Receiver| is a hub for an owner object to asynchronously receive messages and calls from other objects living on different async dispatchers.
Summary
A |Receiver| should be embedded as a member variable of an owner object which wishes to receive messages. The receiver will silently discard pending messages when it destructs, typically as part of its parent.
The |Receiver| is thread-unsafe, and must be used and managed from a synchronized dispatcher.
Calls posted to the same |Receiver| will be processed in the order they are made, regardless which |Function|s and |Callback|s they are made from.
Calls posted to different |Receiver|s living on the same dispatcher are not guaranteed to be processed before or after one another.
Inheritance
Inherits from: async_patterns::internal::ReceiverBase
Constructors and Destructors |
|
---|---|
Receiver(Owner *owner, async_dispatcher_t *dispatcher)
Constructs a receiver.
|
|
Receiver(const Receiver &)
|
|
Receiver(Receiver &&)
|
Public functions |
|
---|---|
Once(Member Owner::*member)
|
auto
Mints a |Callback| object that holds a capability to send |Args| to the owner object once.
|
Once(StatelessLambda callable)
|
auto
Mints a |Callback| object that holds a capability to send |Args| to the owner object once.
|
Repeating(Member Owner::*member)
|
auto
Mints a |Function| object that holds a capability to send |Args| to the owner object repeatedly.
|
Repeating(StatelessLambda callable)
|
auto
Mints a |Function| object that holds a capability to send |Args| to the owner object repeatedly.
|
operator=(const Receiver &)=delete
|
Receiver &
|
operator=(Receiver &&)=delete
|
Receiver &
|
Public functions
Once
auto Once( Member Owner::*member )
Mints a |Callback| object that holds a capability to send |Args| to the owner object once.
When the resulting |Callback| is invoked on some other thread, |member| is scheduled to be called on the |dispatcher|.
|member| should be a pointer to member function. It should have the function signature void Owner::SomeMember(Args...)
where Args are some number of arguments.
Once
auto Once( StatelessLambda callable )
Mints a |Callback| object that holds a capability to send |Args| to the owner object once.
When the resulting |Callback| is invoked on some other thread, |callable| is scheduled to be called on the |dispatcher|.
|callable| should be a lambda without any captures. It should have the function signature void(Owner*, Args...)
where Args are some number of arguments.
Receiver
Receiver( Owner *owner, async_dispatcher_t *dispatcher )
Constructs a receiver.
|owner| should be this
. |dispatcher| should be the dispatcher that the current task is running on, and where |Owner| typically lives.
Receiver
Receiver( const Receiver & )=delete
Receiver
Receiver( Receiver && )=delete
Repeating
auto Repeating( Member Owner::*member )
Mints a |Function| object that holds a capability to send |Args| to the owner object repeatedly.
When the resulting |Function| is invoked on some other thread, |member| is scheduled to be called on the |dispatcher|.
|member| should be a pointer to member function. It should have the function signature void Owner::SomeMember(Args...)
where Args are some number of arguments.
Repeating
auto Repeating( StatelessLambda callable )
Mints a |Function| object that holds a capability to send |Args| to the owner object repeatedly.
When the resulting |Function| is invoked on some other thread, |callable| is scheduled to be called on the |dispatcher|.
|callable| should be a lambda without any captures. It should have the function signature void(Owner*, Args...)
where Args are some number of arguments.