summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorIvo van Dongen <info@ivovandongen.nl>2017-08-08 10:42:44 +0300
committerIvo van Dongen <ivovandongen@users.noreply.github.com>2017-08-08 11:36:30 +0300
commit68f470fdda4e31d7704fba3e41bb2f899db39541 (patch)
tree439153bc9a62a5ed46d335cb8f6b9020d146a1f1 /test
parent2dd8ec885453b6c75d982dd90722e583b2da3525 (diff)
downloadqtlocation-mapboxgl-68f470fdda4e31d7704fba3e41bb2f899db39541.tar.gz
[core] make actor self reference optional - again
- uses a different method of constructor selection that also works on Apple clang < 8.2.
Diffstat (limited to 'test')
-rw-r--r--test/actor/actor.test.cpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/test/actor/actor.test.cpp b/test/actor/actor.test.cpp
index 2b4c83f566..4c7fc3666d 100644
--- a/test/actor/actor.test.cpp
+++ b/test/actor/actor.test.cpp
@@ -305,3 +305,34 @@ TEST(Actor, Ask) {
ASSERT_EQ(std::future_status::ready, status);
ASSERT_EQ(2, result.get());
}
+
+TEST(Actor, NoSelfActorRef) {
+ // Not all actors need a reference to self
+
+ // Trivially constructable
+ struct Trivial {};
+
+ ThreadPool pool { 2 };
+ Actor<Trivial> trivial(pool);
+
+
+ // With arguments
+ struct WithArguments {
+ std::promise<void> promise;
+
+ WithArguments(std::promise<void> promise_)
+ : promise(std::move(promise_)) {
+ }
+
+ void receive() {
+ promise.set_value();
+ }
+ };
+
+ std::promise<void> promise;
+ auto future = promise.get_future();
+ Actor<WithArguments> withArguments(pool, std::move(promise));
+
+ withArguments.invoke(&WithArguments::receive);
+ future.wait();
+}