diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2015-06-08 19:19:48 -0400 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2015-07-01 15:21:10 -0700 |
commit | f14e4c67fdea1796f1cce105256f181e54d8473f (patch) | |
tree | 4198943f040cdd0991602f7652da914ddd3b0dd5 /src | |
parent | 5fadda53e5cf7044ead3a3e688c557c7af290453 (diff) | |
download | qtlocation-mapboxgl-f14e4c67fdea1796f1cce105256f181e54d8473f.tar.gz |
Add comment about a subtlety
Diffstat (limited to 'src')
-rw-r--r-- | src/mbgl/util/run_loop.hpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/mbgl/util/run_loop.hpp b/src/mbgl/util/run_loop.hpp index 3b753aca88..14021ef42f 100644 --- a/src/mbgl/util/run_loop.hpp +++ b/src/mbgl/util/run_loop.hpp @@ -42,6 +42,17 @@ public: std::move(fn), std::move(tuple)); + // `task` is a shared pointer with ownership in the following three places: + // 1. In the `queue` of pending invocations. + // 2. In the `WorkRequest` result. + // 3. In the lambda binding of the callback to be executed on the invoking + // RunLoop. This last shared ownership is necessary in the case where + // callback execution has been scheduled (queued on the invoking RunLoop), + // but the other two places have released ownership -- i.e. the task was + // cancelled after the work is completed, but before the callback is + // executed. In this case, the lambda binding checks the cancellation flag + // and does not execute the original callback. + task->bind(callback); withMutex([&] { queue.push(task); }); |