Creating a high priority task runner and a low priority task runner for the same sequence?

433 views
Skip to first unread message

Daniel Cheng

unread,
May 1, 2023, 7:45:44 PM5/1/23
to scheduler-dev, rhal...@chromium.org
I think the UI thread has some notion of this based on https://source.chromium.org/chromium/chromium/src/+/refs/heads/main:content/browser/scheduler/browser_task_queues.h;l=41;drc=78c31bec509b26c4fd92b386be58bf2fe3f14d91, but IIUC, it's built on top of base::SequenceManager, and that header looks a bit daunting without an example in the comments. Is there a simple way of doing this that already exists, or would we need to write our own?

(The use case here is prioritizing certain Mojo messages over others)

Daniel

Etienne Pierre-doray

unread,
May 2, 2023, 3:56:56 AM5/2/23
to Daniel Cheng, scheduler-dev, rhal...@chromium.org
This CL creates a new kUserInput queue that's kHighestPriority (see changes in content/public/browser).
 content::GetUIThreadTaskRunner({BrowserTaskType::kUserInput}) gets a task runner from this queue.

--
You received this message because you are subscribed to the Google Groups "scheduler-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scheduler-de...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/scheduler-dev/CAF3XrKqCWAjRLbpNHy8e_dKMtstN8i_NU46vScgBfviZEh%2BOuA%40mail.gmail.com.

Gabriel Charette

unread,
May 3, 2023, 4:28:12 PM5/3/23
to Etienne Pierre-doray, Daniel Cheng, scheduler-dev, rhal...@chromium.org
The default priority for content::GetUIThreadTaskRunner() is already base::TaskPriority::USER_BLOCKING (most tasks are a result of user interaction and hence this default makes the most sense).

To prioritize above that you need to specify (and probably add) a content::BrowserTaskType and define its underlying priority in content/browser/scheduler (BrowserTaskExecutor IIRC but offline as I write this)

Daniel Cheng

unread,
May 4, 2023, 2:42:47 AM5/4/23
to Gabriel Charette, Etienne Pierre-doray, scheduler-dev, rhal...@chromium.org
What if I want to do this in a utility process, where presumably there is no UI thread?

Daniel

Gabriel Charette

unread,
May 4, 2023, 8:07:49 AM5/4/23
to Daniel Cheng, Gabriel Charette, Etienne Pierre-doray, scheduler-dev, rhal...@chromium.org
Then you'll have to install a SequenceManager on the main thread, like BrowserTaskExecutor does.

The simplest example is SingleThreadTaskExecutor.

In fact, every non-pooled thread in Chrome, even base::Thread, has a SequenceManager (in the simple cases with only a single task queue).
Reply all
Reply to author
Forward
0 new messages