summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2017-05-16 11:35:26 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2017-05-17 09:28:26 -0700
commit4c26759b69bf1c5ef12b244562784f97d773315f (patch)
tree1dd045f2d8fd33e60a1ab562018a263ce1e16561
parentc2f7f48a223a2a3ba7bf6c8eb2f405edd77a9593 (diff)
downloadqtlocation-mapboxgl-4c26759b69bf1c5ef12b244562784f97d773315f.tar.gz
[core] Remove WorkQueue
No longer used as of 5cdf838a387cae446dba500ac49a1c5524bf7949.
-rw-r--r--cmake/core-files.cmake2
-rw-r--r--cmake/test-files.cmake1
-rw-r--r--src/mbgl/text/glyph_atlas.hpp1
-rw-r--r--src/mbgl/util/work_queue.cpp38
-rw-r--r--src/mbgl/util/work_queue.hpp40
-rw-r--r--test/util/work_queue.test.cpp59
6 files changed, 0 insertions, 141 deletions
diff --git a/cmake/core-files.cmake b/cmake/core-files.cmake
index 47b34fcbc0..90b8d97afe 100644
--- a/cmake/core-files.cmake
+++ b/cmake/core-files.cmake
@@ -602,7 +602,5 @@ set(MBGL_CORE_FILES
src/mbgl/util/utf.hpp
src/mbgl/util/version.cpp
src/mbgl/util/version.hpp
- src/mbgl/util/work_queue.cpp
- src/mbgl/util/work_queue.hpp
src/mbgl/util/work_request.cpp
)
diff --git a/cmake/test-files.cmake b/cmake/test-files.cmake
index 9415add573..e4ffba4754 100644
--- a/cmake/test-files.cmake
+++ b/cmake/test-files.cmake
@@ -138,5 +138,4 @@ set(MBGL_TEST_FILES
test/util/timer.test.cpp
test/util/token.test.cpp
test/util/url.test.cpp
- test/util/work_queue.test.cpp
)
diff --git a/src/mbgl/text/glyph_atlas.hpp b/src/mbgl/text/glyph_atlas.hpp
index f4c4601530..8a672afe6e 100644
--- a/src/mbgl/text/glyph_atlas.hpp
+++ b/src/mbgl/text/glyph_atlas.hpp
@@ -7,7 +7,6 @@
#include <mbgl/util/noncopyable.hpp>
#include <mbgl/util/optional.hpp>
#include <mbgl/util/font_stack.hpp>
-#include <mbgl/util/work_queue.hpp>
#include <mbgl/util/image.hpp>
#include <mbgl/gl/texture.hpp>
#include <mbgl/gl/object.hpp>
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
diff --git a/test/util/work_queue.test.cpp b/test/util/work_queue.test.cpp
deleted file mode 100644
index 60c72f7358..0000000000
--- a/test/util/work_queue.test.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-#include <mbgl/test/util.hpp>
-
-#include <mbgl/util/run_loop.hpp>
-#include <mbgl/util/thread.hpp>
-#include <mbgl/util/work_queue.hpp>
-
-#include <thread>
-
-using namespace mbgl::util;
-
-class TestThread {
-public:
- TestThread(WorkQueue* queue_) : queue(queue_) {}
-
- void send(std::function<void()>&& fn) {
- queue->push(std::move(fn));
- }
-
-private:
- WorkQueue* queue;
-};
-
-TEST(WorkQueue, push) {
- RunLoop loop;
-
- WorkQueue queue;
- Thread<TestThread> thread({"Test"}, &queue);
-
- uint8_t count = 0;
-
- auto endTest = [&]() {
- if (++count == 4) {
- loop.stop();
- }
- };
-
- thread.invoke(&TestThread::send, endTest);
- thread.invoke(&TestThread::send, endTest);
- thread.invoke(&TestThread::send, endTest);
- thread.invoke(&TestThread::send, endTest);
-
- loop.run();
-}
-
-TEST(WorkQueue, cancel) {
- RunLoop loop;
-
- WorkQueue queue;
-
- auto work = [&]() {
- FAIL() << "Should never be called";
- };
-
- queue.push(work);
- queue.push(work);
- queue.push(work);
- queue.push(work);
- queue.push(work);
-}