Hello:
I have a simple class to do simple thread-safe logging using recursive_mutex as shown below. The problem is, once in a while, it causes any
--- In Boost-Users@y..., "Ani Taggu"
while it tries to log. I haven't been able to isolate why this happens. Is recursive_mutex being used correctly?
I'm not sure I can answer why threads would "die". I'm going to assume there's an exception being thrown in the thread, but that's just a guess. I will comment on your logger, though. It's flawed. The stream library provided on your platform/compiler already provide the level of thread synchronization that your logger does. The problem is that this level of thread synchronization granularity is not enough. Consider your use case: TheLog() << "Hello World" << endl; The stream is synchronized when outputting "Hello World" and when outputting the "endl" manipulator, but not between these two seperate calls. This means your output can be interleaved, and basically be unreadable because of this. You really want to make the entire output sequence syncrhonized. I'm also uncertain why you'd use a recursive_mutex in this case? Bill Kempf