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

Issue 26389005: SkThreadPool: allow for Runnables that add other Runnables to the pool. (Closed)

Created:
7 years, 2 months ago by mtklein
Modified:
7 years, 2 months ago
Reviewers:
bungeman-skia, bsalomon
CC:
skia-review_googlegroups.com
Visibility:
Public.

Description

SkThreadPool: allow for Runnables that add other Runnables to the pool. There's a scenario that we're currently not allowing for, but I'd really like to use in DM: 1) client calls add(SomeRunnable*) several times 2) client calls wait() 3) any of the runnables added by the client _themselves_ call add(SomeOtherRunnable*) 4-inf) maybe those SomeOtherRunnables too call add(SomeCrazyThirdRunnable*), etc. Right now in this scenario we'll assert in debug mode in step 3) when we call add() and we're waiting to stop, and do strange unspecified things in release mode. The old threadpool had basically two states: running, and waiting to stop. If a thread saw we were waiting to stop and the queue was empty, that thread shut down. This wasn't accounting for any work that other threads might be doing; potentially they were about to add to the queue. So now we have three states: running, waiting, and halting. When the client calls wait() (or the destructor triggers), we move into waiting. When a thread notices we're _really_ done, that is, have an empty queue and there are no active threads, we move into halting. The halting state actually triggers the threads to stop, which wait() is patiently join()ing on. BUG= Committed: http://code.google.com/p/skia/source/detail?r=11852

Patch Set 1 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+31 lines, -11 lines) Patch
M include/utils/SkThreadPool.h View 1 chunk +11 lines, -4 lines 0 comments Download
M src/utils/SkThreadPool.cpp View 6 chunks +20 lines, -7 lines 0 comments Download

Messages

Total messages: 7 (0 generated)
mtklein
Testing: debug/release tests, debug/release dm --config 565 8888, which triggered the problem originally.
7 years, 2 months ago (2013-10-16 20:43:43 UTC) #1
bungeman-skia
lgtm
7 years, 2 months ago (2013-10-17 20:12:36 UTC) #2
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://skia-tree-status.appspot.com/cq/mtklein@google.com/26389005/1
7 years, 2 months ago (2013-10-18 13:59:54 UTC) #3
commit-bot: I haz the power
Presubmit check for 26389005-1 failed and returned exit status 1. Running presubmit commit checks ...
7 years, 2 months ago (2013-10-18 13:59:58 UTC) #4
bsalomon
lgtm
7 years, 2 months ago (2013-10-18 14:08:40 UTC) #5
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://skia-tree-status.appspot.com/cq/mtklein@google.com/26389005/1
7 years, 2 months ago (2013-10-18 14:09:04 UTC) #6
commit-bot: I haz the power
7 years, 2 months ago (2013-10-18 14:19:27 UTC) #7
Message was sent while issue was closed.
Change committed as 11852

Powered by Google App Engine
This is Rietveld 408576698