What is a task queue in chrome code database

131 views
Skip to first unread message

18楼梦想改造家

unread,
Sep 23, 2023, 11:48:03 PM9/23/23
to scheduler-dev
Hey, I read this document: [Chromium Docs - Threading and Tasks in Chrome (googlesource.com)](https://chromium.googlesource.com/chromium/src/+/main/docs/threading_and_tasks.md#Posting-to-the-Main-Thread-or-to-the-IO-Thread-in-the-Browser-Process).

And found this:

> Note that SequencedTaskRunner::GetCurrentDefault() returns the default queue for the current virtual thread. On threads with multiple task queues (e.g. BrowserThread::UI) this can be a different queue than the one the current task belongs to.

If I don't misunderstand anything:

```
OneThread==>task1->task2->task3 queue_a
                 ||
                 ==> task4->task5     queue_b

```
This is above dodument want to describe. In one (virtual) thread, we have two queues(one is queue_a, another is queue_b)

If we at task4 to call `|GetCurrentDefault|`, and `|queue_a|` is the default queue. we will return `|queue_a|` instead of `|queue_b|`. That't what the document want to say, Does I understand this right? or not.

And another question is , in chormium, which class map to `|queue_a|` and `|queue_b|`. Thx.

I ask this question becuase, think about we have this [code](https://chromium.googlesource.com/chromium/src/+/main/docs/threading_and_tasks.md#Posting-to-the-Main-Thread-or-to-the-IO-Thread-in-the-Browser-Process):

```
scoped_refptr<SequencedTaskRunner> sequenced_task_runner =
    base::ThreadPool::CreateSequencedTaskRunner(...);

// TaskB runs after TaskA completes.
sequenced_task_runner->PostTask(FROM_HERE, base::BindOnce(&TaskA));
sequenced_task_runner->PostTask(FROM_HERE, base::BindOnce(&TaskB));
```


When I debug the code in a debugger, and assume now the code already running in `|TaskA|`, If I know which queue is the `|TaskA|` belong to, then I could dump the queue in the debugger, then I could know which task will be run after `TaskA`(here is TaskB).
Reply all
Reply to author
Forward
0 new messages