Commit a3ccc977 authored by Gabriel Charette's avatar Gabriel Charette Committed by Commit Bot

[Threading docs] Clarify why a sequence is thread-safe.

As requested on the bug.

R=fdoray@chromium.org

Bug: 736531
Change-Id: I8f1fda7cc7e5973c72b2c9ff970c8a88620e0ca5
Reviewed-on: https://chromium-review.googlesource.com/c/1332768
Commit-Queue: François Doray <fdoray@chromium.org>
Reviewed-by: default avatarFrançois Doray <fdoray@chromium.org>
Cr-Commit-Position: refs/heads/master@{#607585}
parent a266e4d0
...@@ -190,8 +190,13 @@ base::SequencedTaskRunnerHandle::Get()-> ...@@ -190,8 +190,13 @@ base::SequencedTaskRunnerHandle::Get()->
## Using Sequences Instead of Locks ## Using Sequences Instead of Locks
Usage of locks is discouraged in Chrome. Sequences inherently provide Usage of locks is discouraged in Chrome. Sequences inherently provide
thread-safety. Prefer classes that are always accessed from the same sequence to thread-safety. Prefer classes that are always accessed from the same
managing your own thread-safety with locks. sequence to managing your own thread-safety with locks.
**Thread-safe but not thread-affine; how so?** Tasks posted to the same sequence
will run in sequential order. After a sequenced task completes, the next task
may be picked up by a different worker thread, but that task is guaranteed to
see any side-effects caused by the previous one(s) on its sequence.
```cpp ```cpp
class A { class A {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment