blob: 0eccb872fdc3c52c458b10878ee81273c879c0ea [file] [log] [blame]
// Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "wimax_manager/event_dispatcher.h"
#include <base/location.h>
#include <base/threading/thread_task_runner_handle.h>
namespace wimax_manager {
EventDispatcher::EventDispatcher()
: dont_use_directly_(new(std::nothrow) base::MessageLoopForUI),
task_runner_(base::ThreadTaskRunnerHandle::Get()) {
CHECK(dont_use_directly_.get());
}
void EventDispatcher::DispatchForever() {
base::MessageLoop::current()->Run();
}
bool EventDispatcher::PostTask(const base::Closure &task) {
return task_runner_->PostTask(FROM_HERE, task);
}
bool EventDispatcher::PostDelayedTask(
const base::Closure &task, const base::TimeDelta &delay) {
return task_runner_->PostDelayedTask(FROM_HERE, task, delay);
}
void EventDispatcher::Stop() {
base::MessageLoop::current()->PostTask(
FROM_HERE, base::MessageLoop::QuitWhenIdleClosure());
}
} // namespace wimax_manager