summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2015-04-10 15:36:32 +0200
committerKonstantin Käfer <mail@kkaefer.com>2015-04-10 15:36:32 +0200
commitbba3d9838a512c75a63f5eb9263913ec96011e8d (patch)
treeafe1462c6e134fffae55fceaae45a8920e63644b /bin
parent8eafe36932c3c5407a305268bc5b62e70ad8b8b0 (diff)
downloadqtlocation-mapboxgl-bba3d9838a512c75a63f5eb9263913ec96011e8d.tar.gz
add Thread<T> and RunLoop
Thread<T> is a generic thread management object that starts a thread, creates an object T in that thread and calls its .start() function. When the Thread<T> object is destructed (which must happen in the thread that created it), it'll call the object's .stop() function, and wait for thread termination. The .stop() function must somehow get the thread to terminate. Note that object T's constructor/destructor/start()/stop() must be protected/private, and Thread<T> must be declared as a friend class. All public functions may be called from any thread and are exposed through operator->(). RunLoop encapsulates a libuv runloop and has a facility of dispatching function objects to the thread. It can be used either as a worker thread class by itself, or it can be derived from. This commit converts SQLiteCache to derive from RunLoop and removes the custom code used previously for managing the cache thread.
Diffstat (limited to 'bin')
-rw-r--r--bin/render.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/bin/render.cpp b/bin/render.cpp
index 01f6929092..879bf840a2 100644
--- a/bin/render.cpp
+++ b/bin/render.cpp
@@ -2,6 +2,7 @@
#include <mbgl/util/image.hpp>
#include <mbgl/util/std.hpp>
#include <mbgl/util/io.hpp>
+#include <mbgl/util/thread.hpp>
#include <mbgl/platform/default/headless_view.hpp>
#include <mbgl/platform/default/headless_display.hpp>
@@ -66,8 +67,8 @@ int main(int argc, char *argv[]) {
using namespace mbgl;
- mbgl::SQLiteCache cache(cache_file);
- mbgl::DefaultFileSource fileSource(&cache);
+ mbgl::util::Thread<mbgl::SQLiteCache> cache(cache_file);
+ mbgl::DefaultFileSource fileSource(cache);
// Try to load the token from the environment.
if (!token.size()) {