File: README.md

package info (click to toggle)
chromium 139.0.7258.127-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,122,068 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (55 lines) | stat: -rw-r--r-- 2,133 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# //net/base/task

This directory provides a mechanism for obtaining `base::SingleThreadTaskRunner`
instances that are integrated with task scheduling and prioritization system of
the embedder process (e.g network service).

## Overview

The primary API offered is:

```cpp
namespace net {

const scoped_refptr<base::SingleThreadTaskRunner>& GetTaskRunner(
    RequestPriority priority);

}  // namespace net
```

This function allows code (typically running on the network thread or
interacting closely with network operations) to post tasks with a specific
`net::RequestPriority`.

## Integration with Network Service Scheduler

The `NetworkServiceScheduler` (located in `//services/network/scheduler/`) is
responsible for setting up and managing the actual task queues on the network
service thread, including a high-priority queue.

During its initialization (specifically in `SetupNetTaskRunners()`), the
`NetworkServiceScheduler` populates
`net::internal::GetTaskRunnerGlobals().high_priority_task_runner` with the task
runner associated with its own high-priority queue.

This ensures that when `net::GetTaskRunner(net::HIGHEST)` is called, tasks
posted to the returned runner are routed to the network service's designated
high-priority processing queue.

## Usage

Components that need to schedule work on the network thread with specific
network-related priorities should use `net::GetTaskRunner()`. This helps ensure
that critical network tasks (like those with `net::HIGHEST` priority) are
processed appropriately by the network service's scheduler.

If `RequestPriority` is unavailable or you are unsure which `priority` should be
used, continue to use `base::SingleThreadTaskRunner::GetCurrentDefault()` as
usual. This is currently equivalent to calling `net::GetTaskRunner(priority)`
for any `priority` except `net::HIGHEST`.

Task execution order is not guaranteed if you post tasks to different queues. If
you need posted tasks to be executed in order, use the same task runner.

The mapping of `RequestPriority` to underlying `TaskQueue` is subject to change.
Please do not write code that depends on this mapping.