Boost logo

Boost Users :

From: Damien McGivern (d_mcgivern_at_[hidden])
Date: 2004-02-12 11:17:44


Thanks both to Geert and Ben for the quick reply.

>join() waits for the thread to *end*. This should be
done
>after the threads have been told to Stop().

>I thought Java's join() was exactly the same.

Yeah I caught the problem when I had another look at
the code earlier - I don't know what I was thinking.

>Here are the bugs I found:
>
>- Runnable::_running is read and written from
multiple
> threads without use of a mutex.
>- The result of QueueAccessor::Pop is undefined if
the queue
> is empty. Perhaps it should throw in this case?
>- The return type of QueueAccessor::Size should be
> std::queue<QueueItem>::size_type (which I think is
> std::size_t).
>- QueueAccessor::Size doesn't lock the mutex for the
queue.
>
>- Reader::Do busy-waits for input. It should wait on
a
> condition variable instead. (Condition variables
provide
> functions equivalent to the wait, notify and
notifyAll
> methods that Object has in Java.) Worse, when the
> reader is asked to stop, Reader::Do may never
return to
> Worker::Run and so the thread will never stop.
>- CommandQueueTest.hpp doesn't include <iostream>.
>- #include <name> is reserved for use with system
headers.
> You should use #include "name" for including your
own
> headers.
>- Identifiers that include "__" are reserved for the
use
> of the implementation. You must not use them.
>- Many member variables are protected when they
should
> be private.
>
>I have fixed most of the above and the program now
works.
>
>Ben.

Cheers for pointing out the bugs much appreciated.

mcgiv

        
        
                
___________________________________________________________
BT Yahoo! Broadband - Free modem offer, sign up online today and save £80 http://btyahoo.yahoo.co.uk


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net