Re: [Boost-users] 2. TRY boost::thread - problem with worker as an inner class of a queue
Sorry, I have have shortened the code to some degree - taking the joins out. But the problem really seams to be in the constructor:
QueueError( ST max_queue_size =1000 ) : max_queue__size__( max_queue_size ) , thread_( Worker( this )) {};
In all examples given in the in boost::threads global or static member functions are called - is that neccessary??? Thank, Lars
Lars Kunert wrote:
Sorry, I have have shortened the code to some degree - taking the joins out. But the problem really seams to be in the constructor:
QueueError( ST max_queue_size =1000 ) : max_queue__size__( max_queue_size ) , thread_( Worker( this )) {};
You're right, there's a problem in the constructor as well. Specifically,
private: ST max_queue_size_; Queue queue_;
Thread thread_;
boost::mutex monitor_; boost::condition space_available_, job_available_;
thread_ is constructed before monitor_ and can end up trying to lock it before its construction has completed.
participants (2)
-
Lars Kunert
-
Peter Dimov