Boost logo

Boost :

From: Thorsten Ottosen (nesotto_at_[hidden])
Date: 2004-03-12 20:29:03


"Tom Widmer" <tom_usenet_at_[hidden]> wrote in message
news:tcl350tm80fqpbma96j3jcsa6i6o3t9dm6_at_4ax.com...
[snip]
> Your code does have at least two major errors:
>
> mutex::scoped_lock lock( mutex );
> is a function declaration (demonstrating the danger of C++ and "using
> namespace boost"). You meant:
> mutex::scoped_lock lock(queue_mutex);

Doh! I dont get why this cold compile at all!

> Also, you have implemented a stack rather than a queue; the reader
> should use front() and pop_front(). This didn't make much difference
> to the benchmark.

yeah it doesn't.

> You should also probably using condition variables rather than
> thread::yield - thread::yield is rarely needed in properly written
> multithreaded code (although I've been lucky enough to write most of
> my threading code in a realtime operating system with deterministic
> scheduling).

Ok, I'm no MT expert, but I haven't seen any examples of how to do this.
It would explain why you have to hack so much to call yield :-)

> But in any case, your benchmark does prove a point - circular_buffer
> seems a bit unnecessary if you have a properly implemented std::deque,
> as found in Dinkumware's library for one. No ongoing memory allocation
> has to happen in std::deque either! This is because it can use a
> circular buffer for the map of blocks, and not throw away empty
> blocks.

ok.

br

Thorsten


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk