Questions tagged [boost-mutex]

The mutual exclusion classes of the Boost.Thread library are designed to serialize access to resources shared between C++ threads.

89 questions
2
votes
1 answer

can mutex hang execution?

I am fairly new to using mutexes seriously. After implementing a few mutexes in various places, I realized that program execution hangs (not exit). I tried to debug it (in eclipse environment) but I couldn't reach a definite reason(or at least i…
rahman
  • 4,820
  • 16
  • 52
  • 86
2
votes
1 answer

Segmentation fault by locking a mutex

I'm here to ask your opinion. I'm new in a big project so I will try to describe the simple example as I see it. The top backtrace is #0 0xb6adfc6d in pthread_mutex_lock () from /usr/lib/libpthread.so.0 #1 0x080d8565 in boost::mutex::lock() () #2 …
Torrius
  • 737
  • 3
  • 12
  • 20
2
votes
1 answer

How do I extend C++ boost list container to implement a thread safe implementation using boost upgrade mutex?

I wrote some sample test code to verify the functionality of using boost upgrade mutexes to implement a read/write mutex lock over a boost list container. I have ten threads, 5 are readers, 5 are writers. I used smart pointers to simplify memory…
2
votes
1 answer

Why not to use boost::mutex within shared memory compared to boost::interprocess_mutex?

Having now for a while been learning and using boost shared memory in anger I've arrived at a mental model, of when to use what type of mutex, that looks like this: class IntendedToResideInProcessMemory { boost::mutex mutex_for_this_process; //…
Benedict
  • 2,771
  • 20
  • 21
1
vote
1 answer

Boost named_mutex unable to be shared across processes that are created by different users

I have a problem in sharing a boost named mutex across processes, which are created by different users. The first process is created by service, which logon as LocalSystem. The second process is created by myself (just execute the process…
1
vote
1 answer

Release boost::mutex from destructor

As std::vector isn't thread-safe, I was trying to build a very simple encapsulation around it which makes it thread-safe. This works quite well, but there's one little problem. When the instance of the class is being destructed and another thread is…
Atmocreations
  • 9,923
  • 15
  • 67
  • 102
1
vote
0 answers

Access violation in custom serial server class in MSVC++ 6.0 using boost threads

I have an application that needs to be able to accept commands from the ethernet, serial port, and/or GUI, process them, and then output the results over the ethernet and serial channels. The host OS is Windows NT4.0, so I'm limited to MSVC++ 6.0…
1
vote
2 answers

Cannot use boost::shared_mutex

I have a small template class with a non-static member of type boost::shared_mutex. Whenever I try to compile it, I get the error: 'boost::shared_mutex::shared_mutex' : cannot access private member declared in class 'boost::shared_mutex'.…
Violet Giraffe
  • 32,368
  • 48
  • 194
  • 335
1
vote
1 answer

What is the difference in boost::shared_mutex vs boost::upgrade_mutex?

I was wondering what the difference is in boost::shared_mutex and boost::upgrade_mutex. I wanted to make a multi threaded application that will have multiple frequent readers and one non frequent writer. I could just use a standard shared_mutex and…
av4625
  • 303
  • 1
  • 11
1
vote
0 answers

How to trace code to find out which mutex causes problem

I have some code with many functions and threads and many different mutexes. Some times the code works well and some times I get one of these errors 1) "/usr/include/boost/thread/pthread/mutex.hpp:111: boost::mutex::~mutex(): Assertion '!res'…
zahra
  • 175
  • 1
  • 10
1
vote
2 answers

Unexplained behavior boost::scoped_lock

I am wrote on C++ multithread TCP server, for synchronization using boost:scoped_lock After connecting to server client freezes. in gdb i saw more threads in pthread_kill after call boost::mutex::lock (gdb) info thread 277 Thread 808779c00 (LWP…
Nikola
  • 61
  • 5
1
vote
1 answer

Using boost::mutex as a private member of class

I have a class that contains a boost::mutex as a private member. It becomes locked when you call one of its public functions and unlocks when the function exits. This is to provide synchronous access to the object's internals. class StringDeque { …
T Lytle
  • 177
  • 2
  • 13
1
vote
1 answer

error: no matching function for call to 'boost::shared_lock::shared_lock(const Lock&)'

I have implemented a ReadLock like following: In my myClass.h #include #include typedef boost::shared_mutex Lock; typedef boost::shared_lock< Lock > ReadLock; Lock myLock; In…
John Yang
  • 547
  • 1
  • 8
  • 21
1
vote
1 answer

boost::scoped_lock appears not to lock std::cout

I'm using boost 1.54.0 and Visual Studio 2010. For the code: #include #include "boost/thread/thread.hpp" #include "boost/thread/mutex.hpp" boost::mutex mx1; void func1() { { boost::mutex::scoped_lock(mx1); std::cout…
zappyzap
  • 43
  • 4
1
vote
1 answer

Why does mutex try_lock return false even when you own the mutex?

Consider this simple code: boost::mutex m; m.lock(); bool locked = m.try_lock(); std::cout<< (!locked? "Can't use lock" : "Can use lock.")<
Tomáš Zato
  • 50,171
  • 52
  • 268
  • 778