Keyboard Shortcuts

File
u :up to issue
m :publish + mail comments
M :edit review message
j / k :jump to file after / before current file
J / K :jump to next file with a comment after / before current file
Side-by-side diff
i :toggle intra-line diffs
e :expand all comments
c :collapse all comments
s :toggle showing all comments
n / p :next / previous diff chunk or comment
N / P :next / previous comment
<Up> / <Down> :next / previous line
<Enter> :respond to / edit current comment
d :mark current comment as done
Issue
u :up to list of issues
m :publish + mail comments
j / k :jump to patch after / before current patch
o / <Enter> :open current patch in side-by-side view
i :open current patch in unified diff view
Issue List
j / k :jump to issue after / before current issue
o / <Enter> :open current issue
# : close issue
Comment/message editing
<Ctrl> + s or <Ctrl> + Enter :save comment
<Esc> :cancel edit
Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(98)
Issues Repositories Search
Open Issues | Closed Issues | All Issues | Sign in with your Google Account to create issues and add comments

Issue 1678062: Adding thread_pool to the GCL namespace.

Can't Edit
Can't Publish+Mail
Start Review
Created:
15 years, 5 months ago by ChrisM
Modified:
14 years, 12 months ago
Reviewers:
Alasdair, Adam, Jeffrey Yasskin, lawrence
CC:
google-concurrency-library_googlegroups.com
Visibility:
Public.
Adds in a very basic thread pool (no ability to add new events). Contains basic functionality for pausing/starting the pool and counting the number of active threads. Support for delayed execution is offloaded to the alarm service. A more complex form which allows enqueue of new tasks will be added later.

Patch Set 1 #

Patch Set 2 : Updated code to get threads to pass + a couple of new test. #

Total comments: 12

Patch Set 3 : Removed the num_active_threads function for the time being. #

Total comments: 1
Created: 15 years, 4 months ago
Download [raw] [tar.bz2]
Unified diffs Side-by-side diffs Delta from patch set Stats (+449 lines, -3 lines) Patch
M Makefile View 3 chunks +4 lines, -3 lines 0 comments Download
M include/source.h View 1 chunk +2 lines, -0 lines 0 comments Download
M include/thread.h View 2 chunks +6 lines, -0 lines 0 comments Download
A include/thread_pool.h View 1 2 1 chunk +75 lines, -0 lines 0 comments Download
A src/thread_pool.cc View 1 2 1 chunk +113 lines, -0 lines 1 comment Download
A testing/thread_pool_test.cc View 1 2 1 chunk +249 lines, -0 lines 0 comments Download
Total messages: 6
|
ChrisM
Hey guys, ping since the thread pool is now working and passing all of its ...
15 years, 5 months ago (2010年08月09日 07:07:48 UTC) #1
Hey guys, ping since the thread pool is now working and passing all of its
tests.
Sign in to reply to this message.
Alasdair
Just a couple of quick comments. Will take a closer look tomorrow. http://codereview.appspot.com/1678062/diff/2001/3004 File include/thread_pool.h ...
15 years, 5 months ago (2010年08月17日 01:41:49 UTC) #2
Just a couple of quick comments. Will take a closer look tomorrow.
http://codereview.appspot.com/1678062/diff/2001/3004
File include/thread_pool.h (right):
http://codereview.appspot.com/1678062/diff/2001/3004#newcode67
include/thread_pool.h:67: vector<atomic_int> thread_states;
Would it be better to use atomic<ThreadState>?
http://codereview.appspot.com/1678062/diff/2001/3004#newcode74
include/thread_pool.h:74: PoolState pool_state;
I believe we're using Google style member variables, with trailing underscores?
http://codereview.appspot.com/1678062/diff/2001/3005
File src/thread_pool.cc (right):
http://codereview.appspot.com/1678062/diff/2001/3005#newcode20
src/thread_pool.cc:20: thread_states(pool_size, atomic_int()),
I think the thread_states are going to have an undefined value until they
actually start running. Do we need to initialise the thread_states here?
http://codereview.appspot.com/1678062/diff/2001/3005#newcode55
src/thread_pool.cc:55: pool_state_mu.unlock();
Don't think we need this if we're using a unique lock.
http://codereview.appspot.com/1678062/diff/2001/3005#newcode90
src/thread_pool.cc:90: // Wait for there something to be in the queue. Even if
the queue is closed
"to be something"
http://codereview.appspot.com/1678062/diff/2001/3005#newcode100
src/thread_pool.cc:100: // If the pool is paused
Something missing on the end of this sentence?
Sign in to reply to this message.
ChrisM
http://codereview.appspot.com/1678062/diff/2001/3004 File include/thread_pool.h (right): http://codereview.appspot.com/1678062/diff/2001/3004#newcode67 include/thread_pool.h:67: vector<atomic_int> thread_states; On 2010年08月17日 01:41:50, Alasdair wrote: > Would ...
15 years, 4 months ago (2010年08月27日 04:01:40 UTC) #3
http://codereview.appspot.com/1678062/diff/2001/3004
File include/thread_pool.h (right):
http://codereview.appspot.com/1678062/diff/2001/3004#newcode67
include/thread_pool.h:67: vector<atomic_int> thread_states;
On 2010年08月17日 01:41:50, Alasdair wrote:
> Would it be better to use atomic<ThreadState>?
I've removed the thread states anyway.
http://codereview.appspot.com/1678062/diff/2001/3004#newcode74
include/thread_pool.h:74: PoolState pool_state;
On 2010年08月17日 01:41:50, Alasdair wrote:
> I believe we're using Google style member variables, with trailing
underscores?
Done.
http://codereview.appspot.com/1678062/diff/2001/3005
File src/thread_pool.cc (right):
http://codereview.appspot.com/1678062/diff/2001/3005#newcode20
src/thread_pool.cc:20: thread_states(pool_size, atomic_int()),
On 2010年08月17日 01:41:50, Alasdair wrote:
> I think the thread_states are going to have an undefined value until they
> actually start running. Do we need to initialise the thread_states here?
Thread states are gone for now.
http://codereview.appspot.com/1678062/diff/2001/3005#newcode55
src/thread_pool.cc:55: pool_state_mu.unlock();
True
On 2010年08月17日 01:41:50, Alasdair wrote:
> Don't think we need this if we're using a unique lock.
http://codereview.appspot.com/1678062/diff/2001/3005#newcode90
src/thread_pool.cc:90: // Wait for there something to be in the queue. Even if
the queue is closed
On 2010年08月17日 01:41:50, Alasdair wrote:
> "to be something"
Done.
http://codereview.appspot.com/1678062/diff/2001/3005#newcode100
src/thread_pool.cc:100: // If the pool is paused
On 2010年08月17日 01:41:50, Alasdair wrote:
> Something missing on the end of this sentence?
Done.
Sign in to reply to this message.
Lawrence_Crowl.org
Why does the thread pool need to be a friend of the source source and ...
15 years, 3 months ago (2010年09月24日 17:15:11 UTC) #4
Why does the thread pool need to be a friend of the source
source and the thread class?
What is the user-side interface to the thread pool?
On 8/26/10, ccmysen@gmail.com <ccmysen@gmail.com> wrote:
>
> http://codereview.appspot.com/1678062/diff/2001/3004
> File include/thread_pool.h (right):
>
> http://codereview.appspot.com/1678062/diff/2001/3004#newcode67
> include/thread_pool.h:67: vector<atomic_int> thread_states;
> On 2010年08月17日 01:41:50, Alasdair wrote:
>
> > Would it be better to use atomic<ThreadState>?
> >
>
> I've removed the thread states anyway.
>
> http://codereview.appspot.com/1678062/diff/2001/3004#newcode74
> include/thread_pool.h:74: PoolState pool_state;
> On 2010年08月17日 01:41:50, Alasdair wrote:
>
> > I believe we're using Google style member variables, with trailing
> >
> underscores?
>
> Done.
>
> http://codereview.appspot.com/1678062/diff/2001/3005
> File src/thread_pool.cc (right):
>
> http://codereview.appspot.com/1678062/diff/2001/3005#newcode20
> src/thread_pool.cc:20: thread_states(pool_size, atomic_int()),
> On 2010年08月17日 01:41:50, Alasdair wrote:
>
> > I think the thread_states are going to have an undefined value until
> >
> they
>
> > actually start running. Do we need to initialise the thread_states
> >
> here?
>
> Thread states are gone for now.
>
> http://codereview.appspot.com/1678062/diff/2001/3005#newcode55
> src/thread_pool.cc:55: pool_state_mu.unlock();
> True
> On 2010年08月17日 01:41:50, Alasdair wrote:
>
> > Don't think we need this if we're using a unique lock.
> >
>
> http://codereview.appspot.com/1678062/diff/2001/3005#newcode90
> src/thread_pool.cc:90: // Wait for there something to be in the queue.
> Even if the queue is closed
> On 2010年08月17日 01:41:50, Alasdair wrote:
>
> > "to be something"
> >
>
> Done.
>
> http://codereview.appspot.com/1678062/diff/2001/3005#newcode100
> src/thread_pool.cc:100: // If the pool is paused
> On 2010年08月17日 01:41:50, Alasdair wrote:
>
> > Something missing on the end of this sentence?
> >
>
> Done.
>
> http://codereview.appspot.com/1678062/
>
-- 
Lawrence Crowl
Sign in to reply to this message.
ChrisM
This is currently being re-written (i've got it half implemented at the moment, though not ...
15 years, 3 months ago (2010年09月24日 17:23:21 UTC) #5
This is currently being re-written (i've got it half implemented at the
moment, though not fully).
I'll ping (hopefully next week) when i've gotten it mostly done.
In terms of the interface, though, there basically isn't any interface at
the moment. You construct the pool and hand it a source and it just goes
until the source closes or you stop the pool.
In the new form with pipelines and growable thread pools, there will be a
slightly wider interface which will let you to call execute() which will
basically just add to the sink and there will probably (i'm leaving it out
for now) be an interface for providing hints as to when to grow/collapse the
pool. I'm currently using the java thread pool design, though, of growing
the thread pool only when work is backed up and reducing the size when there
is no work to do for multiple threads in the pool.
-c
On Fri, Sep 24, 2010 at 10:14 AM, Lawrence Crowl <Lawrence@crowl.org> wrote:
> Why does the thread pool need to be a friend of the source
> source and the thread class?
>
> What is the user-side interface to the thread pool?
>
> On 8/26/10, ccmysen@gmail.com <ccmysen@gmail.com> wrote:
> >
> > http://codereview.appspot.com/1678062/diff/2001/3004
> > File include/thread_pool.h (right):
> >
> > http://codereview.appspot.com/1678062/diff/2001/3004#newcode67
> > include/thread_pool.h:67: vector<atomic_int> thread_states;
> > On 2010年08月17日 01:41:50, Alasdair wrote:
> >
> > > Would it be better to use atomic<ThreadState>?
> > >
> >
> > I've removed the thread states anyway.
> >
> > http://codereview.appspot.com/1678062/diff/2001/3004#newcode74
> > include/thread_pool.h:74: PoolState pool_state;
> > On 2010年08月17日 01:41:50, Alasdair wrote:
> >
> > > I believe we're using Google style member variables, with trailing
> > >
> > underscores?
> >
> > Done.
> >
> > http://codereview.appspot.com/1678062/diff/2001/3005
> > File src/thread_pool.cc (right):
> >
> > http://codereview.appspot.com/1678062/diff/2001/3005#newcode20
> > src/thread_pool.cc:20: thread_states(pool_size, atomic_int()),
> > On 2010年08月17日 01:41:50, Alasdair wrote:
> >
> > > I think the thread_states are going to have an undefined value until
> > >
> > they
> >
> > > actually start running. Do we need to initialise the thread_states
> > >
> > here?
> >
> > Thread states are gone for now.
> >
> > http://codereview.appspot.com/1678062/diff/2001/3005#newcode55
> > src/thread_pool.cc:55: pool_state_mu.unlock();
> > True
> > On 2010年08月17日 01:41:50, Alasdair wrote:
> >
> > > Don't think we need this if we're using a unique lock.
> > >
> >
> > http://codereview.appspot.com/1678062/diff/2001/3005#newcode90
> > src/thread_pool.cc:90: // Wait for there something to be in the queue.
> > Even if the queue is closed
> > On 2010年08月17日 01:41:50, Alasdair wrote:
> >
> > > "to be something"
> > >
> >
> > Done.
> >
> > http://codereview.appspot.com/1678062/diff/2001/3005#newcode100
> > src/thread_pool.cc:100: // If the pool is paused
> > On 2010年08月17日 01:41:50, Alasdair wrote:
> >
> > > Something missing on the end of this sentence?
> > >
> >
> > Done.
> >
> > http://codereview.appspot.com/1678062/
> >
>
>
> --
> Lawrence Crowl
>
Sign in to reply to this message.
Alasdair
http://codereview.appspot.com/1678062/diff/9001/src/thread_pool.cc File src/thread_pool.cc (right): http://codereview.appspot.com/1678062/diff/9001/src/thread_pool.cc#newcode83 src/thread_pool.cc:83: Note from meeting, 14/1/11. When we get here, we've ...
14 years, 12 months ago (2011年01月14日 19:49:51 UTC) #6
http://codereview.appspot.com/1678062/diff/9001/src/thread_pool.cc
File src/thread_pool.cc (right):
http://codereview.appspot.com/1678062/diff/9001/src/thread_pool.cc#newcode83
src/thread_pool.cc:83: 
Note from meeting, 14/1/11. When we get here, we've popped a value off the
queue. We shouldn't break (even if shutting down) without somehow consuming the
value. (Or putting it back on the queue???)
Sign in to reply to this message.
|
Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b

AltStyle によって変換されたページ (->オリジナル) /