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

Unified Diff: include/AdblockPlus/Scheduler.h

Issue 29499621: Issue 4983 - Get rid of Sleep() in the WebRequest test (Closed) Base URL: https://github.com/adblockplus/libadblockplus.git
Patch Set: Created July 27, 2017, 10:18 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
« no previous file with comments | « include/AdblockPlus/JsEngine.h ('k') | libadblockplus.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/AdblockPlus/Scheduler.h
diff --git a/src/DefaultWebRequest.cpp b/include/AdblockPlus/Scheduler.h
similarity index 57%
copy from src/DefaultWebRequest.cpp
copy to include/AdblockPlus/Scheduler.h
index 50af59ae9dd74c92f0a150b61dab721dd60ac786..a0ded9d8c6f2667b672588ca1f3553637a310fa2 100644
--- a/src/DefaultWebRequest.cpp
+++ b/include/AdblockPlus/Scheduler.h
@@ -15,26 +15,19 @@
* along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "DefaultWebRequest.h"
-#include <thread>
+#ifndef ADBLOCK_PLUS_SCHEDULER_H
+#define ADBLOCK_PLUS_SCHEDULER_H
-using namespace AdblockPlus;
-
-DefaultWebRequest::DefaultWebRequest(std::unique_ptr<DefaultWebRequestSync>&& syncImpl)
- : syncImpl(std::move(syncImpl))
+namespace AdblockPlus
{
+ /**
+ * Task object which can be passed to `Scheduler` to be executed asynchronously.
+ */
+ typedef std::function<void()> SchedulerTask;
+ /**
+ * Scheduler object executing tasks asynchronously.
+ */
+ typedef std::function<void(const SchedulerTask&)> Scheduler;
}
-
-DefaultWebRequest::~DefaultWebRequest()
-{
-
-}
-
-void DefaultWebRequest::GET(const std::string& url, const HeaderList& requestHeaders, const GetCallback& getCallback)
-{
- std::thread([this, url, requestHeaders, getCallback]
- {
- getCallback(this->syncImpl->GET(url, requestHeaders));
- }).detach();
-}
+#endif // ADBLOCK_PLUS_SCHEDULER_H
« no previous file with comments | « include/AdblockPlus/JsEngine.h ('k') | libadblockplus.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld