Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(185)

Unified Diff: mojo/edk/system/test/test_io_thread.cc

Issue 1496663002: EDK: Make mojo::platform::TaskRunner's PostTask() take an std::function<void()>. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/edk/system/test/test_io_thread.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/system/test/test_io_thread.cc
diff --git a/mojo/edk/system/test/test_io_thread.cc b/mojo/edk/system/test/test_io_thread.cc
index eaa218a9fa06707598ce8b204e02e4610e76cf06..c425f6f4236a68bcf3918ce8dd83b524fd2024ac 100644
--- a/mojo/edk/system/test/test_io_thread.cc
+++ b/mojo/edk/system/test/test_io_thread.cc
@@ -4,7 +4,8 @@
#include "mojo/edk/system/test/test_io_thread.h"
-#include "base/bind.h"
+#include <utility>
+
#include "mojo/edk/util/waitable_event.h"
using mojo::util::AutoResetWaitableEvent;
@@ -14,16 +15,6 @@ namespace mojo {
namespace system {
namespace test {
-namespace {
-
-void PostTaskAndWaitHelper(AutoResetWaitableEvent* event,
- const base::Closure& task) {
- task.Run();
- event->Signal();
-}
-
-} // namespace
-
TestIOThread::TestIOThread(StartMode start_mode)
: io_thread_("test_io_thread"), io_thread_started_(false) {
switch (start_mode) {
@@ -60,16 +51,27 @@ bool TestIOThread::IsCurrentAndRunning() const {
io_thread_.message_loop()->is_running();
}
+void TestIOThread::PostTask(std::function<void()>&& task) {
+ io_task_runner_->PostTask(std::move(task));
+}
+
void TestIOThread::PostTask(const base::Closure& task) {
io_task_runner_->PostTask(task);
}
-void TestIOThread::PostTaskAndWait(const base::Closure& task) {
+void TestIOThread::PostTaskAndWait(std::function<void()>&& task) {
AutoResetWaitableEvent event;
- io_task_runner_->PostTask(base::Bind(&PostTaskAndWaitHelper, &event, task));
+ io_task_runner_->PostTask([&task, &event]() {
+ task();
+ event.Signal();
+ });
event.Wait();
}
+void TestIOThread::PostTaskAndWait(const base::Closure& task) {
+ PostTaskAndWait([&task]() { task.Run(); });
+}
+
} // namespace test
} // namespace system
} // namespace mojo
« no previous file with comments | « mojo/edk/system/test/test_io_thread.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698