blob: 4e01665f07621e8e56cf0a70a1531e0748e9841d [file] [log] [blame]
Sebastian Jansson0d617cc2019-03-22 15:22:16 +01001/*
2 * Copyright 2019 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10#include "test/time_controller/real_time_controller.h"
11
12#include "api/task_queue/global_task_queue_factory.h"
13#include "rtc_base/event.h"
14#include "rtc_base/task_utils/to_queued_task.h"
15#include "system_wrappers/include/sleep.h"
16
17namespace webrtc {
18
19Clock* RealTimeController::GetClock() {
20 return Clock::GetRealTimeClock();
21}
22
23TaskQueueFactory* RealTimeController::GetTaskQueueFactory() {
24 return &GlobalTaskQueueFactory();
25}
26
27std::unique_ptr<ProcessThread> RealTimeController::CreateProcessThread(
28 const char* thread_name) {
29 return ProcessThread::Create(thread_name);
30}
31
32void RealTimeController::Sleep(TimeDelta duration) {
33 SleepMs(duration.ms());
34}
35
36void RealTimeController::InvokeWithControlledYield(
37 std::function<void()> closure) {
38 closure();
39}
40
Sebastian Jansson5d97f552019-04-15 14:43:03 +020041RealTimeController* GlobalRealTimeController() {
42 static RealTimeController* time_controller = new RealTimeController();
43 return time_controller;
44}
45
Sebastian Jansson0d617cc2019-03-22 15:22:16 +010046} // namespace webrtc