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

Issue 2892993002: Make RunLoop::Quit() thread-safe. (Closed)

Created:
3 years, 7 months ago by gab
Modified:
3 years, 7 months ago
Reviewers:
danakj
CC:
chromium-reviews, danakj+watch_chromium.org, vmpstr+watch_chromium.org, fdoray
Target Ref:
refs/heads/master
Project:
chromium
Visibility:
Public.

Description

Make RunLoop::Quit() thread-safe. It was already safe to call it off-sequence as of r472835. But making it thread-safe is key to enabling use cases like: RunLoop run_loop_; <post a task binding run_loop_.QuitClosure() to task scheduler> run_loop_.Run(); e.g. happens in https://codereview.chromium.org/2881143002/ without this CL Run() and Quit() are racing in this situation as the posted task may run at any point after being posted. FYI, RunLoop() already supports being Quit() prior to being Run() so the race resolving either way is fine, it just needs to be thread-safe. BUG=722537 Review-Url: https://codereview.chromium.org/2892993002 Cr-Commit-Position: refs/heads/master@{#473378} Committed: https://chromium.googlesource.com/chromium/src/+/cf5e4ce0c0eff930821b2459ee03d161ab4d6550

Patch Set 1 #

Total comments: 4

Patch Set 2 : add tests that call Quit(WhenIdle) directly, without the Quit(WhenIdle)Closure #

Unified diffs Side-by-side diffs Delta from patch set Stats (+216 lines, -12 lines) Patch
M base/run_loop.h View 5 chunks +22 lines, -5 lines 0 comments Download
M base/run_loop.cc View 6 chunks +55 lines, -5 lines 0 comments Download
M base/run_loop_unittest.cc View 1 3 chunks +139 lines, -2 lines 0 comments Download

Messages

Total messages: 15 (8 generated)
gab
Dana PTaL, thanks!
3 years, 7 months ago (2017-05-19 17:37:56 UTC) #3
danakj
https://codereview.chromium.org/2892993002/diff/1/base/run_loop.cc File base/run_loop.cc (right): https://codereview.chromium.org/2892993002/diff/1/base/run_loop.cc#newcode27 base/run_loop.cc:27: if (task_runner->RunsTasksInCurrentSequence()) { This if (on thread) A else ...
3 years, 7 months ago (2017-05-19 18:11:30 UTC) #6
danakj
https://codereview.chromium.org/2892993002/diff/1/base/run_loop_unittest.cc File base/run_loop_unittest.cc (right): https://codereview.chromium.org/2892993002/diff/1/base/run_loop_unittest.cc#newcode130 base/run_loop_unittest.cc:130: other_sequence->PostTask(FROM_HERE, run_loop_.QuitClosure()); These tests all verify QuitClosure() but not ...
3 years, 7 months ago (2017-05-19 18:53:34 UTC) #7
gab
Tests added PTanL https://codereview.chromium.org/2892993002/diff/1/base/run_loop.cc File base/run_loop.cc (right): https://codereview.chromium.org/2892993002/diff/1/base/run_loop.cc#newcode27 base/run_loop.cc:27: if (task_runner->RunsTasksInCurrentSequence()) { On 2017/05/19 18:11:30, ...
3 years, 7 months ago (2017-05-19 19:38:17 UTC) #8
danakj
LGTM
3 years, 7 months ago (2017-05-19 19:38:53 UTC) #9
commit-bot: I haz the power
CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2892993002/20001
3 years, 7 months ago (2017-05-19 19:41:17 UTC) #12
commit-bot: I haz the power
3 years, 7 months ago (2017-05-19 22:57:16 UTC) #15
Message was sent while issue was closed.
Committed patchset #2 (id:20001) as
https://chromium.googlesource.com/chromium/src/+/cf5e4ce0c0eff930821b2459ee03...

Powered by Google App Engine
This is Rietveld 408576698