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

Unified Diff: test/BaseJsTest.cpp

Issue 29499583: Issue 4938 - fix race conditions related to LazyFileSystem (Closed) Base URL: https://github.com/adblockplus/libadblockplus.git
Patch Set: Created July 27, 2017, 8:53 a.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
Index: test/BaseJsTest.cpp
diff --git a/test/BaseJsTest.cpp b/test/BaseJsTest.cpp
index 53c80a0c649847534cba510087d29f69ab7e7c00..e8d2dd3f051feeb7328337b87fb349de94eb7929 100644
--- a/test/BaseJsTest.cpp
+++ b/test/BaseJsTest.cpp
@@ -16,6 +16,9 @@
*/
#include "BaseJsTest.h"
+#include <AdblockPlus/FilterEngine.h>
+
+using namespace AdblockPlus;
void DelayedTimer::ProcessImmediateTimers(DelayedTimer::SharedTasks& timerTasks)
{
@@ -49,3 +52,26 @@ AdblockPlus::JsEnginePtr CreateJsEngine(JsEngineCreationParameters&& jsEngineCre
std::move(jsEngineCreationParameters.logSystem));
return jsEngine;
}
+
+FilterEnginePtr CreateFilterEngine(LazyFileSystem& fileSystem,
+ const JsEnginePtr& jsEngine,
+ const FilterEngine::CreationParameters& creationParams)
+{
+ std::list<LazyFileSystem::Task> fileSystemTasks;
+ fileSystem.scheduler = [&fileSystemTasks](const LazyFileSystem::Task& task)
+ {
+ fileSystemTasks.emplace_back(task);
+ };
+ FilterEnginePtr retValue;
+ FilterEngine::CreateAsync(jsEngine, [&retValue, &fileSystem](const FilterEnginePtr& filterEngine)
+ {
+ retValue = filterEngine;
+ fileSystem.scheduler = LazyFileSystem::ExecuteImmediately;
+ }, creationParams);
+ while (!retValue && !fileSystemTasks.empty())
+ {
+ (*fileSystemTasks.begin())();
+ fileSystemTasks.pop_front();
+ }
+ return retValue;
+}
« no previous file with comments | « test/BaseJsTest.h ('k') | test/FilterEngine.cpp » ('j') | test/FilterEngine.cpp » ('J')

Powered by Google App Engine
This is Rietveld