summaryrefslogtreecommitdiff
path: root/include/mbgl
diff options
context:
space:
mode:
authorIvo van Dongen <info@ivovandongen.nl>2017-09-18 13:39:47 +0300
committerIvo van Dongen <ivovandongen@users.noreply.github.com>2017-09-22 23:33:56 +0300
commit8b9794b1a7276d8ea2957d5aed7169fc0b40e25d (patch)
treee42da349f705a15dca3521e5535b558a79866659 /include/mbgl
parentc17be060fd910dbcaf7334356743421ac6936e7e (diff)
downloadqtlocation-mapboxgl-8b9794b1a7276d8ea2957d5aed7169fc0b40e25d.tar.gz
[core] Actor/ActorRef - ask calls to void methods
- allows to wait for execution of void methods as well as non-void methods
Diffstat (limited to 'include/mbgl')
-rw-r--r--include/mbgl/actor/message.hpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/include/mbgl/actor/message.hpp b/include/mbgl/actor/message.hpp
index 406de425d4..0a20993352 100644
--- a/include/mbgl/actor/message.hpp
+++ b/include/mbgl/actor/message.hpp
@@ -64,6 +64,32 @@ public:
std::promise<ResultType> promise;
};
+template <class Object, class MemberFn, class ArgsTuple>
+class AskMessageImpl<void, Object, MemberFn, ArgsTuple> : public Message {
+public:
+ AskMessageImpl(std::promise<void> promise_, Object& object_, MemberFn memberFn_, ArgsTuple argsTuple_)
+ : object(object_),
+ memberFn(memberFn_),
+ argsTuple(std::move(argsTuple_)),
+ promise(std::move(promise_)) {
+ }
+
+ void operator()() override {
+ ask(std::make_index_sequence<std::tuple_size<ArgsTuple>::value>());
+ promise.set_value();
+ }
+
+ template <std::size_t... I>
+ void ask(std::index_sequence<I...>) {
+ (object.*memberFn)(std::move(std::get<I>(argsTuple))...);
+ }
+
+ Object& object;
+ MemberFn memberFn;
+ ArgsTuple argsTuple;
+ std::promise<void> promise;
+};
+
namespace actor {
template <class Object, class MemberFn, class... Args>