
Hello, Am Sunday 08 March 2009 15:29:05 schrieb Edouard A.:
Unfortunately, I am unable to compile the tp library. TT
Hmm - did you try version 23? I've no problems to compile default_pool( gcc-4.3).
By the way, why didn't you write it as:
inline default_pool & get_default_pool() { static default_pool instance(poolsize(thread::hardware_concurrency())); return instance; }
static locals are not thread-safe
This eliminates the need of a .cpp for default_pool.
code-bloading!
Another remark is that I am not sure I understand the raison d'être of the poolsize type. What is the added value to say, "int" or std::size_t. This prevents us from writing
pool accepts multiple integer arguments (poolsize, high_watermark low_watermark,...) - with specific types for each argument the meaning of each arg becomes clear (see scott meyers advise).
When scheduling several tasks with submit, I find it odd that I don't have a pool.wait()
pool::shutdown() or pool::shutdown_now() -> diff. explained in the docs
that would allow me to wait until all tasks are finished (condition_variable-like pattern for example).
Some tests done with parallel "filling" on a concurrent_vector show that tbb does better but threadpool is not humiliated:
a task is finsihed if its result (shared_future) becomes ready -> shared_future< R >task< R >::result() void shared_future< R >::wait() this is clear because threadpool use a single-lock global qeue. I'm working on a lock-free global queue - I hope theadpool becomes faster.
This is how I implemented tp::fill:
template <typename RandomIterator, typename Value> void parallel_fill(RandomIterator first, RandomIterator last, Value v) { typedef typename RandomIterator::difference_type difference_type;
difference_type n = std::distance(first, last);
boost::tp::default_pool p(boost::tp::poolsize(4));
the default pool should already be avaliable - I don't understand why you initialize it with poolsize. Oliver