blob: 5e0044ead277ec9d63724f7520d884980f879693 [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
Danil Chapovalov28de7cf2019-04-12 19:25:06 +020012#include "api/task_queue/default_task_queue_factory.h"
Sebastian Jansson0d617cc2019-03-22 15:22:16 +010013#include "system_wrappers/include/sleep.h"
14
15namespace webrtc {
16
Danil Chapovalov28de7cf2019-04-12 19:25:06 +020017RealTimeController::RealTimeController()
18 : task_queue_factory_(CreateDefaultTaskQueueFactory()) {}
19
Sebastian Jansson0d617cc2019-03-22 15:22:16 +010020Clock* RealTimeController::GetClock() {
21 return Clock::GetRealTimeClock();
22}
23
24TaskQueueFactory* RealTimeController::GetTaskQueueFactory() {
Danil Chapovalov28de7cf2019-04-12 19:25:06 +020025 return task_queue_factory_.get();
Sebastian Jansson0d617cc2019-03-22 15:22:16 +010026}
27
28std::unique_ptr<ProcessThread> RealTimeController::CreateProcessThread(
29 const char* thread_name) {
30 return ProcessThread::Create(thread_name);
31}
32
33void RealTimeController::Sleep(TimeDelta duration) {
34 SleepMs(duration.ms());
35}
36
37void RealTimeController::InvokeWithControlledYield(
38 std::function<void()> closure) {
39 closure();
40}
41
Sebastian Jansson5d97f552019-04-15 14:43:03 +020042RealTimeController* GlobalRealTimeController() {
43 static RealTimeController* time_controller = new RealTimeController();
44 return time_controller;
45}
46
Sebastian Jansson0d617cc2019-03-22 15:22:16 +010047} // namespace webrtc