Boost logo

Boost Users :

Subject: Re: [Boost-users] Adding a thread to a Singleton class
From: Gottlob Frege (gottlobfrege_at_[hidden])
Date: 2010-01-22 11:09:51


On Fri, Jan 22, 2010 at 7:57 AM, Stephen Torri <storri_at_[hidden]> wrote:
> Well I had a chance to sit down and see what was going on with my
> logging project. What I found out is that the call to thread::join in
> the destructor of my logging class is never returning even though the
> thread was signaled to stop running. Below is the code. Since I am new
> to boost threads I am sure I am making a fundamental mistake.
>

Not sure. Try destroying the tracer earlier - ie at the end of main.
Currently it is a global static Singleton and thus is being destroyed
very late. Maybe that shouldn't be a problem, but hard to say, and
easy to try.

P.S. you are still not unlocking your mutex when processing the local_queue.
Try passing the unique_lock into processTraces(lock), then inside:
   1. assert(lock.owns_lock())
   2. lock.unlock after copying, but before the for-loop
   3. lock.lock after for-loop

Tony


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