diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2015-05-01 17:14:06 -0400 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2015-05-01 17:14:06 -0400 |
commit | 24695f6c0274cac8ae17df3765e0cc54c5668047 (patch) | |
tree | fdc9e4ecc85a61fabf3cf0619f1be44a4488e721 /src/mbgl/util/thread.hpp | |
parent | dac4b7d3c95f84358bd475e01aae45e2ca52ddc0 (diff) | |
download | qtlocation-mapboxgl-24695f6c0274cac8ae17df3765e0cc54c5668047.tar.gz |
More bandaids to avoid #1309
Even though we only bind the shared_ptr in the after callback, the
worker thread was still copying the callback and therefore gaining
a shared reference. Here we try to eliminate the copies.
Diffstat (limited to 'src/mbgl/util/thread.hpp')
-rw-r--r-- | src/mbgl/util/thread.hpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/mbgl/util/thread.hpp b/src/mbgl/util/thread.hpp index 415bda38d8..189182464c 100644 --- a/src/mbgl/util/thread.hpp +++ b/src/mbgl/util/thread.hpp @@ -49,14 +49,14 @@ public: // Invoke object->fn(args...) in the runloop thread, then invoke callback(result) in the current thread. template <typename Fn, class R, class... Args> - void invokeWithResult(Fn fn, std::function<void (R)> callback, Args&&... args) { - loop->invokeWithResult(std::bind(fn, object, args...), callback); + void invokeWithResult(Fn fn, std::function<void (R)>&& callback, Args&&... args) { + loop->invokeWithResult(std::bind(fn, object, args...), std::move(callback)); } // Invoke object->fn(args...) in the runloop thread, then invoke callback() in the current thread. template <typename Fn, class... Args> - void invokeWithResult(Fn fn, std::function<void ()> callback, Args&&... args) { - loop->invokeWithResult(std::bind(fn, object, args...), callback); + void invokeWithResult(Fn fn, std::function<void ()>&& callback, Args&&... args) { + loop->invokeWithResult(std::bind(fn, object, args...), std::move(callback)); } // Invoke object->fn(args...) in the runloop thread, and wait for the result. |