Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: src/Platform.cpp

Issue 29508555: Issue 5450 - move FilterEngine into Platform (Closed) Base URL: https://github.com/adblockplus/libadblockplus.git
Patch Set: fix typos Created Aug. 7, 2017, 1:03 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/FilterEngine.cpp ('k') | test/BaseJsTest.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/Platform.cpp
diff --git a/src/Platform.cpp b/src/Platform.cpp
index 11bb1729b9fc115b277874d84eb8e280aa91ab7f..9369d0c78988445ea3869bbfd8e4ebe9dea6681d 100644
--- a/src/Platform.cpp
+++ b/src/Platform.cpp
@@ -78,6 +78,32 @@ std::shared_ptr<JsEngine> Platform::GetJsEngine()
return jsEngine;
}
+void Platform::CreateFilterEngineAsync(const FilterEngine::CreationParameters& parameters,
+ const OnFilterEngineCreatedCallback& onCreated)
+{
+ std::shared_ptr<std::promise<FilterEnginePtr>> filterEnginePromise;
+ {
+ std::lock_guard<std::mutex> lock(modulesMutex);
+ if (filterEngine.valid())
+ return;
+ filterEnginePromise = std::make_shared<std::promise<FilterEnginePtr>>();
+ filterEngine = filterEnginePromise->get_future();
+ }
+
+ FilterEngine::CreateAsync(GetJsEngine(), [this, onCreated, filterEnginePromise](const FilterEnginePtr& filterEngine)
+ {
+ filterEnginePromise->set_value(filterEngine);
+ if (onCreated)
+ onCreated(filterEngine);
+ }, parameters);
+}
+
+FilterEnginePtr Platform::GetFilterEngine()
+{
+ CreateFilterEngineAsync();
+ return std::shared_future<FilterEnginePtr>(filterEngine).get();
+}
+
ITimer& Platform::GetTimer()
{
return *timer;
« no previous file with comments | « src/FilterEngine.cpp ('k') | test/BaseJsTest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld