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

Unified Diff: webrtc/base/task_queue_libevent.cc

Issue 2708353003: Add support for priorities to TaskQueue. (Closed)
Patch Set: Address comments Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/base/task_queue_gcd.cc ('k') | webrtc/base/task_queue_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/base/task_queue_libevent.cc
diff --git a/webrtc/base/task_queue_libevent.cc b/webrtc/base/task_queue_libevent.cc
index c6ce5b3baf3e301550308d407a4866dfd05f8abb..1376ea3f70ee9befcc9468477b9f1ccec9251df4 100644
--- a/webrtc/base/task_queue_libevent.cc
+++ b/webrtc/base/task_queue_libevent.cc
@@ -30,6 +30,8 @@ static const char kQuit = 1;
static const char kRunTask = 2;
static const char kRunReplyTask = 3;
+using Priority = TaskQueue::Priority;
+
// This ignores the SIGPIPE signal on the calling thread.
// This signal can be fired when trying to write() to a pipe that's being
// closed or while closing a pipe that's being written to.
@@ -84,6 +86,21 @@ void EventAssign(struct event* ev,
RTC_CHECK_EQ(0, event_base_set(base, ev));
#endif
}
+
+ThreadPriority TaskQueuePriorityToThreadPriority(Priority priority) {
+ switch (priority) {
+ case Priority::HIGH:
+ return kRealtimePriority;
+ case Priority::LOW:
+ return kLowPriority;
+ case Priority::NORMAL:
+ return kNormalPriority;
+ default:
+ RTC_NOTREACHED();
+ break;
+ }
+ return kNormalPriority;
+}
} // namespace
struct TaskQueue::QueueContext {
@@ -201,10 +218,13 @@ class TaskQueue::SetTimerTask : public QueuedTask {
const uint32_t posted_;
};
-TaskQueue::TaskQueue(const char* queue_name)
+TaskQueue::TaskQueue(const char* queue_name, Priority priority /*= NORMAL*/)
: event_base_(event_base_new()),
wakeup_event_(new event()),
- thread_(&TaskQueue::ThreadMain, this, queue_name) {
+ thread_(&TaskQueue::ThreadMain,
+ this,
+ queue_name,
+ TaskQueuePriorityToThreadPriority(priority)) {
RTC_DCHECK(queue_name);
int fds[2];
RTC_CHECK(pipe(fds) == 0);
« no previous file with comments | « webrtc/base/task_queue_gcd.cc ('k') | webrtc/base/task_queue_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698