diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2017-05-16 11:35:26 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2017-05-17 09:28:26 -0700 |
commit | 4c26759b69bf1c5ef12b244562784f97d773315f (patch) | |
tree | 1dd045f2d8fd33e60a1ab562018a263ce1e16561 /src/mbgl/util | |
parent | c2f7f48a223a2a3ba7bf6c8eb2f405edd77a9593 (diff) | |
download | qtlocation-mapboxgl-4c26759b69bf1c5ef12b244562784f97d773315f.tar.gz |
[core] Remove WorkQueue
No longer used as of 5cdf838a387cae446dba500ac49a1c5524bf7949.
Diffstat (limited to 'src/mbgl/util')
-rw-r--r-- | src/mbgl/util/work_queue.cpp | 38 | ||||
-rw-r--r-- | src/mbgl/util/work_queue.hpp | 40 |
2 files changed, 0 insertions, 78 deletions
diff --git a/src/mbgl/util/work_queue.cpp b/src/mbgl/util/work_queue.cpp deleted file mode 100644 index d0033e3ca2..0000000000 --- a/src/mbgl/util/work_queue.cpp +++ /dev/null @@ -1,38 +0,0 @@ -#include <mbgl/util/work_queue.hpp> -#include <mbgl/util/run_loop.hpp> - -#include <cassert> - -namespace mbgl { -namespace util { - -WorkQueue::WorkQueue() : runLoop(RunLoop::Get()) { -} - -WorkQueue::~WorkQueue() { - assert(runLoop == RunLoop::Get()); - - // Cancel all pending AsyncRequests. - while (!queue.empty()) { - queue.pop(); - } -} - -void WorkQueue::push(std::function<void()>&& fn) { - std::lock_guard<std::mutex> lock(queueMutex); - - auto workRequest = runLoop->invokeCancellable(std::bind(&WorkQueue::pop, this, std::move(fn))); - queue.push(std::move(workRequest)); -} - -void WorkQueue::pop(const std::function<void()>& fn) { - assert(runLoop == RunLoop::Get()); - - fn(); - - std::lock_guard<std::mutex> lock(queueMutex); - queue.pop(); -} - -} // namespace util -} // namespace mbgl diff --git a/src/mbgl/util/work_queue.hpp b/src/mbgl/util/work_queue.hpp deleted file mode 100644 index 3f6328fb57..0000000000 --- a/src/mbgl/util/work_queue.hpp +++ /dev/null @@ -1,40 +0,0 @@ -#pragma once - -#include <mbgl/util/noncopyable.hpp> -#include <mbgl/util/async_request.hpp> - -#include <functional> -#include <memory> -#include <mutex> -#include <queue> - -namespace mbgl { -namespace util { - -class RunLoop; - -// The WorkQueue will manage a queue of closures -// and it will make sure they get executed on the -// thread that created the WorkQueue. All pending -// works are canceled when the queue gets destructed. -class WorkQueue : private util::noncopyable { -public: - WorkQueue(); - ~WorkQueue(); - - // Push a closure to the queue. It is advised to - // only push tasks calling functions on the object - // that owns the queue to avoid use after free errors. - void push(std::function<void()>&&); - -private: - void pop(const std::function<void()>&); - - std::queue<std::unique_ptr<AsyncRequest>> queue; - std::mutex queueMutex; - - RunLoop* runLoop; -}; - -} // namespace util -} // namespace mbgl |