OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 #ifndef WEBRTC_TEST_SINGLE_THREADED_TASK_QUEUE_H_ | 10 #ifndef WEBRTC_TEST_SINGLE_THREADED_TASK_QUEUE_H_ |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 TaskId task_id; | 64 TaskId task_id; |
65 int64_t earliest_execution_time; | 65 int64_t earliest_execution_time; |
66 Task task; | 66 Task task; |
67 }; | 67 }; |
68 | 68 |
69 static void Run(void* obj); | 69 static void Run(void* obj); |
70 | 70 |
71 void RunLoop(); | 71 void RunLoop(); |
72 | 72 |
73 rtc::CriticalSection cs_; | 73 rtc::CriticalSection cs_; |
74 std::list<std::unique_ptr<QueuedTask>> tasks_ GUARDED_BY(cs_); | 74 std::list<std::unique_ptr<QueuedTask>> tasks_ RTC_GUARDED_BY(cs_); |
75 rtc::ThreadChecker owner_thread_checker_; | 75 rtc::ThreadChecker owner_thread_checker_; |
76 rtc::PlatformThread thread_; | 76 rtc::PlatformThread thread_; |
77 bool running_ GUARDED_BY(cs_); | 77 bool running_ RTC_GUARDED_BY(cs_); |
78 | 78 |
79 TaskId next_task_id_; | 79 TaskId next_task_id_; |
80 | 80 |
81 // The task-queue will sleep when not executing a task. Wake up occurs when: | 81 // The task-queue will sleep when not executing a task. Wake up occurs when: |
82 // * Upon destruction, to make sure that the |thead_| terminates, so that it | 82 // * Upon destruction, to make sure that the |thead_| terminates, so that it |
83 // may be joined. [Event will be set.] | 83 // may be joined. [Event will be set.] |
84 // * New task added. Because we optimize for simplicity rahter than for | 84 // * New task added. Because we optimize for simplicity rahter than for |
85 // performance (this class is a testing facility only), waking up occurs | 85 // performance (this class is a testing facility only), waking up occurs |
86 // when we get a new task even if it is scheduled with a delay. The RunLoop | 86 // when we get a new task even if it is scheduled with a delay. The RunLoop |
87 // is in charge of sending itself back to sleep if the next task is only | 87 // is in charge of sending itself back to sleep if the next task is only |
88 // to be executed at a later time. [Event will be set.] | 88 // to be executed at a later time. [Event will be set.] |
89 // * When the next task in the queue is a delayed-task, and the time for | 89 // * When the next task in the queue is a delayed-task, and the time for |
90 // its execution has come. [Event will time-out.] | 90 // its execution has come. [Event will time-out.] |
91 rtc::Event wake_up_; | 91 rtc::Event wake_up_; |
92 }; | 92 }; |
93 | 93 |
94 } // namespace test | 94 } // namespace test |
95 } // namespace webrtc | 95 } // namespace webrtc |
96 | 96 |
97 #endif // WEBRTC_TEST_SINGLE_THREADED_TASK_QUEUE_H_ | 97 #endif // WEBRTC_TEST_SINGLE_THREADED_TASK_QUEUE_H_ |
OLD | NEW |