Add ability to specify delayed task precision in RepeatingTaskHandle.
See go/postdelayedtask-precision-in-webrtc for context of which use cases are considered "high" or "low". Most use cases are "low" which is the default, but this CL allows opting in to "high". Will be used by FrameBuffer2. Bug: webrtc:13604 Change-Id: Iebf6eea44779873e78746da749a39e1101b92819 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/248861 Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org> Commit-Queue: Henrik Boström <hbos@webrtc.org> Cr-Commit-Position: refs/heads/main@{#35776}
This commit is contained in:

committed by
WebRTC LUCI CQ

parent
6f542d5e92
commit
27e8a095bf
@ -25,6 +25,16 @@ namespace webrtc {
|
||||
// known task queue, use IsCurrent().
|
||||
class RTC_LOCKABLE RTC_EXPORT TaskQueueBase {
|
||||
public:
|
||||
enum class DelayPrecision {
|
||||
// This may include up to a 17 ms leeway in addition to OS timer precision.
|
||||
// See PostDelayedTask() for more information.
|
||||
kLow,
|
||||
// This does not have the additional delay that kLow has, but it is still
|
||||
// limited by OS timer precision. See PostDelayedHighPrecisionTask() for
|
||||
// more information.
|
||||
kHigh,
|
||||
};
|
||||
|
||||
// Starts destruction of the task queue.
|
||||
// On return ensures no task are running and no new tasks are able to start
|
||||
// on the task queue.
|
||||
@ -98,6 +108,21 @@ class RTC_LOCKABLE RTC_EXPORT TaskQueueBase {
|
||||
PostDelayedTask(std::move(task), milliseconds);
|
||||
}
|
||||
|
||||
// As specified by |precision|, calls either PostDelayedTask() or
|
||||
// PostDelayedHighPrecisionTask().
|
||||
void PostDelayedTaskWithPrecision(DelayPrecision precision,
|
||||
std::unique_ptr<QueuedTask> task,
|
||||
uint32_t milliseconds) {
|
||||
switch (precision) {
|
||||
case DelayPrecision::kLow:
|
||||
PostDelayedTask(std::move(task), milliseconds);
|
||||
break;
|
||||
case DelayPrecision::kHigh:
|
||||
PostDelayedHighPrecisionTask(std::move(task), milliseconds);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Returns the task queue that is running the current thread.
|
||||
// Returns nullptr if this thread is not associated with any task queue.
|
||||
// May be called on any thread or task queue, including this task queue.
|
||||
|
Reference in New Issue
Block a user