OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef NET_QUIC_QUARTC_QUARTC_TASKRUNNER_INTERFACE_H_ | |
6 #define NET_QUIC_QUARTC_QUARTC_TASKRUNNER_INTERFACE_H_ | |
7 | |
8 namespace net { | |
9 | |
10 // Used by platform specific QuicAlarms. For example, WebRTC will use it to set | |
11 // and cancel an alarm. When setting an alarm, the task runner will schedule a | |
12 // task on rtc::Thread. When canceling an alarm, the canceler for that task will | |
13 // be called. | |
14 class QuartcTaskRunnerInterface { | |
15 public: | |
16 virtual ~QuartcTaskRunnerInterface() {} | |
17 | |
18 class Task { | |
19 public: | |
20 virtual ~Task() {} | |
21 | |
22 // Called when it's time to start the task. | |
23 virtual void Run() = 0; | |
24 }; | |
25 | |
26 // A handler used to cancel a scheduled task. In some cases, a task cannot | |
27 // be directly canceled with its pointer. For example, in WebRTC, the task | |
28 // will be scheduled on rtc::Thread. When canceling a task, its pointer cannot | |
29 // locate the scheduled task in the thread message queue. So when scheduling a | |
30 // task, an additional canceler will be returned. | |
31 class Canceler { | |
pthatcher1
2016/10/14 18:59:00
Like I mentioned, I think ScheduledTask would be a
zhihuang1
2016/10/16 00:45:28
Done.
| |
32 public: | |
33 virtual ~Canceler() {} | |
34 | |
35 // Called when canceling a scheduled task. | |
pthatcher1
2016/10/14 18:59:00
"Cancels a scheduled task, meaning the task will n
zhihuang1
2016/10/16 00:45:28
Done.
| |
36 virtual void Cancel() = 0; | |
37 }; | |
38 | |
39 // Called when scheduling a task. Return a Canceler of the specific task. | |
pthatcher1
2016/10/14 18:59:00
"Schedules a task, which will be run after the giv
zhihuang1
2016/10/16 00:45:28
Done.
| |
40 virtual std::unique_ptr<Canceler> Schedule(Task* task, uint64_t delay_ms) = 0; | |
41 }; | |
42 | |
43 } // namespace net | |
44 | |
45 #endif // NET_QUIC_QUARTC_QUARTC_TASKRUNNER_INTERFACE_H_ | |
OLD | NEW |