|
This helper-class can be used when you have an ice AMD method. More...
#include <ArmarXCore/core/util/distributed/AMDCallbackCollection.h>
Public Types | |
using | ExceptFunction = std::function< void(const std::exception &)> |
using | RespondFunction = std::function< void()> |
Public Member Functions | |
template<class IceCallbackT > | |
void | addCallback (IceUtil::Handle< IceCallbackT > cb) |
Adds an callback and processes it depending on the current mode. More... | |
void | addCallback (RespondFunction onRespond, ExceptFunction onExcept) |
Adds an callback and processes it depending on the current mode. More... | |
AMDCallbackCollection ()=default | |
void | respondeAll () |
All currently stored callbacks will receive a response. More... | |
void | respondeN (std::size_t n) |
The n oldest callbacks will receive a response. More... | |
void | setAutoResponse (bool doAutoResponse=true) |
setAutoResponse More... | |
void | setAutoThrow (std::unique_ptr< std::exception > except) |
If except is null, the mode will be set to Store if it was Except. More... | |
void | storeFurtherCallbacks () |
All future callbacks will be stored. More... | |
void | throwAll (const std::exception &except) |
All currently stored callbacks will receive the exception. More... | |
~AMDCallbackCollection () | |
This helper-class can be used when you have an ice AMD method.
It holds the ice function callbacks or custom fuctions to respond or pass an exception.. Furthermore an excpetion will be passed if this class destroys and some clients are still waiting.
A usecase for this class would be the following scenario: A server S does a long calculation and some clients wait for the result. The server may want to offer a wait function to the clients. Since the server does not want to block threads for waiting the function should be tagged ["amd"] in the slice definition. If a client calls the function, S receives a function callback to send a response or an exception. The server now can use an AMDCallbackCollection to store all callbacks and send an exception or responde to all or some of the stored callbacks.
Definition at line 52 of file AMDCallbackCollection.h.
using ExceptFunction = std::function<void(const std::exception&)> |
Definition at line 55 of file AMDCallbackCollection.h.
using RespondFunction = std::function<void()> |
Definition at line 56 of file AMDCallbackCollection.h.
|
default |
|
inline |
Definition at line 145 of file AMDCallbackCollection.h.
|
inline |
Adds an callback and processes it depending on the current mode.
The callback is created using the ice_response and ice_exception functions of the callback object.
cb | The function callback from ice. |
Definition at line 248 of file AMDCallbackCollection.h.
|
inline |
Adds an callback and processes it depending on the current mode.
onRespond | The function called to responde. |
onExcept | The function called on exception. |
Definition at line 151 of file AMDCallbackCollection.h.
|
inline |
All currently stored callbacks will receive a response.
Definition at line 198 of file AMDCallbackCollection.h.
|
inline |
The n oldest callbacks will receive a response.
n | This may be used in an producer/consumer scenario where the producer creates multiple objects. |
Definition at line 187 of file AMDCallbackCollection.h.
|
inline |
setAutoResponse
doAutoResponse | If set the mode will change to Respond. If false the mode will change from Respond to Store |
Definition at line 169 of file AMDCallbackCollection.h.
|
inline |
If except is null, the mode will be set to Store if it was Except.
If except is not null, all currently stored and future callbacks will receive the exception.
except |
Definition at line 209 of file AMDCallbackCollection.h.
|
inline |
All future callbacks will be stored.
Definition at line 239 of file AMDCallbackCollection.h.
|
inline |
All currently stored callbacks will receive the exception.
except | The exception. |
Definition at line 228 of file AMDCallbackCollection.h.