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

Side by Side Diff: webrtc/base/taskrunner.h

Issue 2620303003: Replace ASSERT by RTC_DCHECK in all non-test code. (Closed)
Patch Set: Address final nits. Created 3 years, 11 months 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 unified diff | Download patch
« no previous file with comments | « webrtc/base/taskparent.cc ('k') | webrtc/base/taskrunner.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2004 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 10
11 #ifndef WEBRTC_BASE_TASKRUNNER_H__ 11 #ifndef WEBRTC_BASE_TASKRUNNER_H__
12 #define WEBRTC_BASE_TASKRUNNER_H__ 12 #define WEBRTC_BASE_TASKRUNNER_H__
13 13
14 #include <stdint.h> 14 #include <stdint.h>
15 15
16 #include <vector> 16 #include <vector>
17 17
18 #include "webrtc/base/checks.h"
18 #include "webrtc/base/sigslot.h" 19 #include "webrtc/base/sigslot.h"
19 #include "webrtc/base/taskparent.h" 20 #include "webrtc/base/taskparent.h"
20 21
21 namespace rtc { 22 namespace rtc {
22 class Task; 23 class Task;
23 24
24 const int64_t kSecToMsec = 1000; 25 const int64_t kSecToMsec = 1000;
25 const int64_t kMsecTo100ns = 10000; 26 const int64_t kMsecTo100ns = 10000;
26 const int64_t kSecTo100ns = kSecToMsec * kMsecTo100ns; 27 const int64_t kSecTo100ns = kSecToMsec * kMsecTo100ns;
27 28
(...skipping 10 matching lines...) Expand all
38 // 39 //
39 // On Windows, GetSystemTimeAsFileTime is the typical implementation. 40 // On Windows, GetSystemTimeAsFileTime is the typical implementation.
40 virtual int64_t CurrentTime() = 0; 41 virtual int64_t CurrentTime() = 0;
41 42
42 void StartTask(Task *task); 43 void StartTask(Task *task);
43 void RunTasks(); 44 void RunTasks();
44 void PollTasks(); 45 void PollTasks();
45 46
46 void UpdateTaskTimeout(Task* task, int64_t previous_task_timeout_time); 47 void UpdateTaskTimeout(Task* task, int64_t previous_task_timeout_time);
47 48
48 #if !defined(NDEBUG) 49 #if RTC_DCHECK_IS_ON
49 bool is_ok_to_delete(Task* task) { 50 bool is_ok_to_delete(Task* task) {
50 return task == deleting_task_; 51 return task == deleting_task_;
51 } 52 }
52 53
53 void IncrementAbortCount() { 54 void IncrementAbortCount() {
54 ++abort_count_; 55 ++abort_count_;
55 } 56 }
56 57
57 void DecrementAbortCount() { 58 void DecrementAbortCount() {
58 --abort_count_; 59 --abort_count_;
(...skipping 20 matching lines...) Expand all
79 // called when no time change has happened. 80 // called when no time change has happened.
80 virtual void OnTimeoutChange() { 81 virtual void OnTimeoutChange() {
81 // by default, do nothing. 82 // by default, do nothing.
82 } 83 }
83 84
84 private: 85 private:
85 void InternalRunTasks(bool in_destructor); 86 void InternalRunTasks(bool in_destructor);
86 void CheckForTimeoutChange(int64_t previous_timeout_time); 87 void CheckForTimeoutChange(int64_t previous_timeout_time);
87 88
88 std::vector<Task *> tasks_; 89 std::vector<Task *> tasks_;
89 Task *next_timeout_task_; 90 Task *next_timeout_task_ = nullptr;
90 bool tasks_running_; 91 bool tasks_running_ = false;
91 #if !defined(NDEBUG) 92 #if RTC_DCHECK_IS_ON
92 int abort_count_; 93 int abort_count_ = 0;
93 Task* deleting_task_; 94 Task* deleting_task_ = nullptr;
94 #endif 95 #endif
95 96
96 void RecalcNextTimeout(Task *exclude_task); 97 void RecalcNextTimeout(Task *exclude_task);
97 }; 98 };
98 99
99 } // namespace rtc 100 } // namespace rtc
100 101
101 #endif // TASK_BASE_TASKRUNNER_H__ 102 #endif // TASK_BASE_TASKRUNNER_H__
OLDNEW
« no previous file with comments | « webrtc/base/taskparent.cc ('k') | webrtc/base/taskrunner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698