Reputation: 965
I suspect that based on the behavior of my code that if I have a boost::thread_group accessing an object protected by a boost::recursive_mutex that the mutex does not prevent threads from within the group from simultaneously entering the protected area.
This is confusing because I see all of the threads listed in the debugger (xcode).
Is this a known issue? I couldn't find any documentation on it.
Upvotes: 1
Views: 148
Reputation: 392911
A boost thread_group is a group of threads.
All the threads are, by definition, distinct and unique.
So, if your mutex fails to... "mut-ex" (mutually exclude) this indicates a programmer error elsewhere.
On a whim, I'd suggest that perhaps your expectations of mutexes (recursive or not) is not accurate (in similar way as the expectations of a thread group were)?
The thing you might have missed is that all parties accessing the shared objects /must/ acquire the mutex at all times of these accesses. It is not enough to have one thread "guard" the shared objects, to magically keep other threads out.
Mutexes are a coöperative proposition. The term "critical section" is actually a bit nicer in this respect: you "mark" the critical sections in code, as opposed to "marking" the critical data (whatever that would be).
Upvotes: 1