Move WorkerTask functionality into RunLoop core

As a byproduct, this makes FileCache get requests properly
cancelable.
This commit is contained in:
John Firebaugh
2015-06-08 18:40:11 -04:00
parent d596d9dc38
commit 5fadda53e5
11 changed files with 201 additions and 152 deletions

View File

@@ -126,12 +126,12 @@ void SQLiteCache::Impl::createSchema() {
}
}
void SQLiteCache::get(const Resource &resource, Callback callback) {
std::unique_ptr<WorkRequest> SQLiteCache::get(const Resource &resource, Callback callback) {
// Can be called from any thread, but most likely from the file source thread.
// Will try to load the URL from the SQLite database and call the callback when done.
// Note that the callback is probably going to invoked from another thread, so the caller
// must make sure that it can run in that thread.
thread->invokeWithResult(&Impl::get, std::move(callback), resource);
return thread->invokeWithResult(&Impl::get, std::move(callback), resource);
}
std::unique_ptr<Response> SQLiteCache::Impl::get(const Resource &resource) {