The mutual exclusion classes of the Boost.Thread library are designed to serialize access to resources shared between C++ threads.
Questions tagged [boost-mutex]
89 questions
0
votes
0 answers
boost or stl class for completely (purely) user space locks in c/c++?
Is there any class exists in boost or std STL, which takes advantages of atomic instructions and implements the synchronization locks which runs only in user space? I am sure that thread will spin continuously to acquire lock with such…

rahul.deshmukhpatil
- 977
- 1
- 16
- 31
0
votes
1 answer
Error : An exception (first chance) at 0x76f6f9d2 in Boost_Mutex.exe: 0xC0000008: An invalid handle was specified
I write a program to test multithreading. In main function a thread t is created. In function D, which is in thread t, two threads tt and ttt will be created. The function Process runs in thread ttt . In Process a member function doAnotherThing of…

rayallen
- 93
- 1
- 1
- 7
0
votes
1 answer
Boost scoped_lock failed every time
In a class, I want to use a mutex over a function like this
void Agent::notify(Packet& packet, Peer peer) {
boost::mutex::scoped_lock lock(mutex_);
...
}
No problem at the compilation process. But when I execute the program, boost always…

Saroupille
- 609
- 8
- 14
0
votes
1 answer
How to correctly use boost::timed_mutex and scoped_lock
I am trying to use both timed_mutex with the scoped_lock. I have successfully used the scoped_lock before by following some examples but now I don't seem to find my way around neither I am able to properly understand the boost documentation.
The…

Pol Alvarez Vecino
- 187
- 5
- 20
0
votes
1 answer
boost mutex in parallel quicksort
This is my first time using mutexes so I am not exactly sure about what I am doing but I think I am having an error with the thread safety of the push_back function using the vector container (I am having multiple threads write to it at the same…

Dan
- 2,647
- 2
- 27
- 37
0
votes
2 answers
Deferring locks and `boost::lock`
I was reading the difference between a lock_guard and a unique_lock and I found out that a unique_lock is an enhanced version of a lock_guard. Such that with a unique lock a lock can always be deferred.I was reading this article and I came across…

Rajeshwar
- 11,179
- 26
- 86
- 158
0
votes
0 answers
Lock Mutex but don't wait for it to be unlocked
How would I lock a std::mutex or boost::mutex so at the start of my method I would lock it, but regardless of it already being locked or not just proceed with the code.
I want this kind of behaviour because there is going to be 2 threads that'll be…

Jeroen
- 15,257
- 12
- 59
- 102
0
votes
1 answer
Hide Boost::mutex from DLL Interface from lockable Container
I've been using Boost in a DLL project but didn't export any Boost dependencies ...yet. Just C-Types and things which derive from the DLL Source tree itself.
But now I'm struggling with a lockable data model... I cannot get it designed exception…

Hhut
- 1,128
- 1
- 12
- 24
0
votes
1 answer
One Writer Many Readers issue for map
I seem to be having an issue synchronizing a data collection. In this particular class, I have a data collection, mutex, and condition variable that looks something like:
map collection;
boost::mutex…

Shaz
- 1,376
- 8
- 18
0
votes
1 answer
creating scoped_lock for 200 ms max
I am trying to create a timed scoped lock on mutex. I thought following api from boost could help but I am having hard time finding some sample code as reference to use it.
scoped_lock(mutex_type & m, const boost::posix_time::ptime & abs_time);
I…

RLT
- 4,219
- 4
- 37
- 91
0
votes
1 answer
Using boost::bind with a class containing a boost::mutex
I'm working on a server using a watchdir to add items to an internal collection. The watchdir is browsed periodically by a thread which is created like this :
this->watchDirThread = new boost::thread(boost::bind(&Filesystem::watchDirThreadLoop,
…

Opera
- 983
- 1
- 6
- 17
0
votes
0 answers
heap corruption and mutex
I have a serious bug in an application, and I try to understand what is going on..
I have some logs just before the crash.
I can't reproduce the bug simply.
the context :
Thread1:
void f()
{
log(thread1_1)
boost::lock_guard<…

Guillaume Paris
- 10,303
- 14
- 70
- 145
0
votes
3 answers
multithreaded program producer/consumer [boost]
I'm playing with boost library and C++. I want to create a multithreaded program that contains a producer, conumer, and a stack. The procuder fills the stack, the consumer remove items (int) from the stack. everything work (pop, push, mutex) But…

ezzakrem
- 399
- 5
- 15
0
votes
3 answers
How do you share a mutex among different instances of a class?
I was wondering how to share a mutex in one class amongst different instances of another class.
Right now, I have a class, Indexer, that has a Boost mutex and condition_variable as private member variables. I create an auto_ptr of the Indexer class…

noko
- 1,129
- 2
- 14
- 25