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

Unified Diff: src/Scheduler.cpp

Issue 29367003: Issue #4711 - Rewrite legacy thread facilities
Patch Set: Created Dec. 7, 2016, 4:44 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
Index: src/Scheduler.cpp
===================================================================
new file mode 100644
--- /dev/null
+++ b/src/Scheduler.cpp
@@ -0,0 +1,38 @@
+/*
+ * This file is part of Adblock Plus <https://adblockplus.org/>,
+ * Copyright (C) 2006-2016 Eyeo GmbH
+ *
+ * Adblock Plus is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3 as
+ * published by the Free Software Foundation.
+ *
+ * Adblock Plus is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "Scheduler.h"
+#include <thread>
+using namespace AdblockPlus;
+
+namespace
+{
+ void SingleUseThreadMain(std::function<void()> task)
+ {
+ task();
+ }
+}
+
+void Scheduler::StartImmediatelyInSingleUseThread(std::function<void()> task)
+{
+ if (!task)
+ {
+ return;
+ }
+ auto th = std::thread(SingleUseThreadMain, task);
sergei 2017/01/16 14:50:13 SingleUseThreadMain is definitely redundant in thi
Eric 2017/01/16 15:20:16 In this commit, yes. It grows in later change sets
hub 2017/05/12 14:45:39 With the other suggestion with task that is a uniq
+ th.detach();
+}

Powered by Google App Engine
This is Rietveld