summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnand Thakker <github@anandthakker.net>2018-06-15 11:25:53 -0400
committerAnand Thakker <github@anandthakker.net>2018-06-15 11:25:53 -0400
commit226c329bcaa98a10e7a75bddac5164f839fc8ba0 (patch)
treea71f360c96cdf5581dc5cdf64edb9275aed65425
parent5cdacf168b43a6c4c4a8e3a502186e5c7d6523b3 (diff)
downloadqtlocation-mapboxgl-226c329bcaa98a10e7a75bddac5164f839fc8ba0.tar.gz
Fixup
-rw-r--r--include/mbgl/util/thread.hpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/include/mbgl/util/thread.hpp b/include/mbgl/util/thread.hpp
index 0cd12f6e95..9eecb64920 100644
--- a/include/mbgl/util/thread.hpp
+++ b/include/mbgl/util/thread.hpp
@@ -49,7 +49,8 @@ public:
// we'll do on the target thread, once its RunLoop and Object instance
// are ready.
// Meanwhile, this allows us to immediately provide ActorRef using this
- // mailbox to queue any messages that come in before the thread is ready.
+ // mailbox to queue any messages that come in before the thread is
+ // ready. (See actor().)
std::shared_ptr<Mailbox> mailbox_ = std::make_shared<Mailbox>();
mailbox = mailbox_;
@@ -68,6 +69,8 @@ public:
util::RunLoop loop_(util::RunLoop::Type::New);
loop = &loop_;
+ // Construct the Actor<Object> into the pre-allocated memory
+ // at `actorStorage`.
Actor<Object>* actor = emplaceActor(
std::move(sharedMailbox),
std::move(tuple),
@@ -116,8 +119,8 @@ public:
// valid until the child thread constructs Actor<Object> into
// actorStorage using "placement new".
// We guarantee that the object reference isn't actually used by
- // using the NoopScheduler to prevent messages to this mailbox from
- // being processed until after the actor has been constructed.
+ // creating this mailbox without a scheduler, and only starting it
+ // after the actor has been constructed.
auto actor = reinterpret_cast<Actor<Object>*>(&actorStorage);
return ActorRef<std::decay_t<Object>>(actor->object, mailbox);
}
@@ -173,7 +176,7 @@ private:
}
std::weak_ptr<Mailbox> mailbox;
- std::aligned_storage<sizeof(Actor<Object>)> actorStorage;
+ std::aligned_storage_t<sizeof(Actor<Object>)> actorStorage;
std::thread thread;