boss-worker model in C++



 DEVELOP > c-Plus-Plus > boss-worker model in C++

LINK TO THIS PAGE  


rating :  0   |  0


  Page 1 of 1

1

 
Topic: DEVELOP > c-Plus-Plus
User: "John"
Date: 21 Feb 2006 04:17:41 AM
Object: boss-worker model in C++
Is there a good implementation of the boss-worker model
in C++ using pthreads? I have an array of objects A that each
need processing and I have p threads running simultaneosly.
Any object can be processed by any thread. All objects need
to get processed.
Does anyone know of a good design/implementation of this problem
in C++?
Thanks a lot for your help,
--j
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
.

User: "Stefan Arentz"

Title: Re: boss-worker model in C++ 22 Feb 2006 06:25:08 PM
"John" <weekender_ny@yahoo.com> writes:

Is there a good implementation of the boss-worker model
in C++ using pthreads? I have an array of objects A that each
need processing and I have p threads running simultaneosly.
Any object can be processed by any thread. All objects need
to get processed.

Does anyone know of a good design/implementation of this problem
in C++?

I got my copy of http://java.sun.com/docs/books/cp/ and implemented
many patterns in a nice C++ manner. Even though it is Java centric,
the book is really excellent as it touches many concurrency issues.
S.
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
.

User: "Maxim Yegorushkin"

Title: Re: boss-worker model in C++ 22 Feb 2006 05:23:08 AM
John wrote:

Is there a good implementation of the boss-worker model
in C++ using pthreads? I have an array of objects A that each
need processing and I have p threads running simultaneosly.
Any object can be processed by any thread. All objects need
to get processed.

Does anyone know of a good design/implementation of this problem
in C++?

You can take an atomic queue from
http://groups.google.com/group/comp.lang.c++.moderated/msg/48b7b7569f04d181
Make the boss thread post jobs (functors) using atomic_queue::push(),
all the worker threads call atomic_queue::pop() and then execute the
job received so.
It uses boost.
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
.

User: "kanze"

Title: Re: boss-worker model in C++ 22 Feb 2006 06:28:41 PM
John wrote:

Is there a good implementation of the boss-worker model in C++
using pthreads? I have an array of objects A that each need
processing and I have p threads running simultaneosly. Any
object can be processed by any thread. All objects need to get
processed.
Does anyone know of a good design/implementation of this
problem in C++?

Wouldn't the usual consumer/producer pattern work? The boss
thread posts requests in a message queue; the worker threads
wait on the message queue, and process requests the extract from
it. In this case, the "request" could be as simple as an int,
the index into the array.
--
James Kanze GABI Software
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
.


  Page 1 of 1

1

 


Related Articles
 

NEWER

pg.1232     pg.940     pg.716     pg.544     pg.412     pg.311     pg.234     pg.175     pg.130     pg.96     pg.70     pg.50     pg.35     pg.24     pg.16     pg.10     pg.6     pg.3     pg.1

OLDER