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

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

Issue 1362503003: Use suffixed {uint,int}{8,16,32,64}_t types. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: rebase + revert basictypes.h (to be landed separately just in case of a revert due to unexpected us… Created 5 years, 2 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/task_unittest.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 <vector> 14 #include <vector>
15 15
16 #include "webrtc/base/basictypes.h" 16 #include "webrtc/base/basictypes.h"
17 #include "webrtc/base/sigslot.h" 17 #include "webrtc/base/sigslot.h"
18 #include "webrtc/base/taskparent.h" 18 #include "webrtc/base/taskparent.h"
19 19
20 namespace rtc { 20 namespace rtc {
21 class Task; 21 class Task;
22 22
23 const int64 kSecToMsec = 1000; 23 const int64_t kSecToMsec = 1000;
24 const int64 kMsecTo100ns = 10000; 24 const int64_t kMsecTo100ns = 10000;
25 const int64 kSecTo100ns = kSecToMsec * kMsecTo100ns; 25 const int64_t kSecTo100ns = kSecToMsec * kMsecTo100ns;
26 26
27 class TaskRunner : public TaskParent, public sigslot::has_slots<> { 27 class TaskRunner : public TaskParent, public sigslot::has_slots<> {
28 public: 28 public:
29 TaskRunner(); 29 TaskRunner();
30 ~TaskRunner() override; 30 ~TaskRunner() override;
31 31
32 virtual void WakeTasks() = 0; 32 virtual void WakeTasks() = 0;
33 33
34 // Returns the current time in 100ns units. It is used for 34 // Returns the current time in 100ns units. It is used for
35 // determining timeouts. The origin is not important, only 35 // determining timeouts. The origin is not important, only
36 // the units and that rollover while the computer is running. 36 // the units and that rollover while the computer is running.
37 // 37 //
38 // On Windows, GetSystemTimeAsFileTime is the typical implementation. 38 // On Windows, GetSystemTimeAsFileTime is the typical implementation.
39 virtual int64 CurrentTime() = 0 ; 39 virtual int64_t CurrentTime() = 0;
40 40
41 void StartTask(Task *task); 41 void StartTask(Task *task);
42 void RunTasks(); 42 void RunTasks();
43 void PollTasks(); 43 void PollTasks();
44 44
45 void UpdateTaskTimeout(Task *task, int64 previous_task_timeout_time); 45 void UpdateTaskTimeout(Task* task, int64_t previous_task_timeout_time);
46 46
47 #ifdef _DEBUG 47 #ifdef _DEBUG
48 bool is_ok_to_delete(Task* task) { 48 bool is_ok_to_delete(Task* task) {
49 return task == deleting_task_; 49 return task == deleting_task_;
50 } 50 }
51 51
52 void IncrementAbortCount() { 52 void IncrementAbortCount() {
53 ++abort_count_; 53 ++abort_count_;
54 } 54 }
55 55
56 void DecrementAbortCount() { 56 void DecrementAbortCount() {
57 --abort_count_; 57 --abort_count_;
58 } 58 }
59 #endif 59 #endif
60 60
61 // Returns the next absolute time when a task times out 61 // Returns the next absolute time when a task times out
62 // OR "0" if there is no next timeout. 62 // OR "0" if there is no next timeout.
63 int64 next_task_timeout() const; 63 int64_t next_task_timeout() const;
64 64
65 protected: 65 protected:
66 // The primary usage of this method is to know if 66 // The primary usage of this method is to know if
67 // a callback timer needs to be set-up or adjusted. 67 // a callback timer needs to be set-up or adjusted.
68 // This method will be called 68 // This method will be called
69 // * when the next_task_timeout() becomes a smaller value OR 69 // * when the next_task_timeout() becomes a smaller value OR
70 // * when next_task_timeout() has changed values and the previous 70 // * when next_task_timeout() has changed values and the previous
71 // value is in the past. 71 // value is in the past.
72 // 72 //
73 // If the next_task_timeout moves to the future, this method will *not* 73 // If the next_task_timeout moves to the future, this method will *not*
74 // get called (because it subclass should check next_task_timeout() 74 // get called (because it subclass should check next_task_timeout()
75 // when its timer goes off up to see if it needs to set-up a new timer). 75 // when its timer goes off up to see if it needs to set-up a new timer).
76 // 76 //
77 // Note that this maybe called conservatively. In that it may be 77 // Note that this maybe called conservatively. In that it may be
78 // called when no time change has happened. 78 // called when no time change has happened.
79 virtual void OnTimeoutChange() { 79 virtual void OnTimeoutChange() {
80 // by default, do nothing. 80 // by default, do nothing.
81 } 81 }
82 82
83 private: 83 private:
84 void InternalRunTasks(bool in_destructor); 84 void InternalRunTasks(bool in_destructor);
85 void CheckForTimeoutChange(int64 previous_timeout_time); 85 void CheckForTimeoutChange(int64_t previous_timeout_time);
86 86
87 std::vector<Task *> tasks_; 87 std::vector<Task *> tasks_;
88 Task *next_timeout_task_; 88 Task *next_timeout_task_;
89 bool tasks_running_; 89 bool tasks_running_;
90 #ifdef _DEBUG 90 #ifdef _DEBUG
91 int abort_count_; 91 int abort_count_;
92 Task* deleting_task_; 92 Task* deleting_task_;
93 #endif 93 #endif
94 94
95 void RecalcNextTimeout(Task *exclude_task); 95 void RecalcNextTimeout(Task *exclude_task);
96 }; 96 };
97 97
98 } // namespace rtc 98 } // namespace rtc
99 99
100 #endif // TASK_BASE_TASKRUNNER_H__ 100 #endif // TASK_BASE_TASKRUNNER_H__
OLDNEW
« no previous file with comments | « webrtc/base/task_unittest.cc ('k') | webrtc/base/taskrunner.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698