summaryrefslogtreecommitdiff
path: root/src/mbgl/storage
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 /src/mbgl/storage
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 'src/mbgl/storage')
-rw-r--r--src/mbgl/storage/default_file_source.cpp6
1 files changed, 1 insertions, 5 deletions
diff --git a/src/mbgl/storage/default_file_source.cpp b/src/mbgl/storage/default_file_source.cpp
index ca8d423b1b..841a56bcef 100644
--- a/src/mbgl/storage/default_file_source.cpp
+++ b/src/mbgl/storage/default_file_source.cpp
@@ -122,11 +122,7 @@ Request *DefaultFileSource::request(const Resource &resource, uv_loop_t *l, cons
void DefaultFileSource::request(const Resource &resource, const Environment &env,
Callback callback) {
- auto req = new Request(resource, nullptr, env, std::move(callback));
-
- // This function can be called from any thread. Make sure we're executing the actual call in the
- // file source loop by sending it over the queue. It will be processed in processAction().
- queue->send(AddRequestAction{ req });
+ request(resource, nullptr, env, std::move(callback));
}
void DefaultFileSource::cancel(Request *req) {