Questions tagged [boost-thread]

Boost.Thread enables the use of multiple threads of execution with shared data in portable C++ code.

Boost.Thread enables the use of multiple threads of execution with shared data in portable C++ code. It provides classes and functions for managing the threads themselves, along with others for synchronizing data between the threads or providing separate copies of data specific to individual threads.

The Boost.Thread library was originally written and designed by William E. Kempf. For Boost 1.35+, Anthony Williams performed a major rewrite designed to closely follow the proposals presented to the C++ Standards Committee, in particular N2497, N2320, N2184, N2139, and N2094.

As of Boost version 1.50.0 Boost.Thread provides an almost complete implementation of the C++ 2011 Threads library, plus extensions such as shared locks and thread interruption.

885 questions
7
votes
2 answers

How to kill or Terminate a boost Thread

I want to terminate or kill boost thread. code is here: DWORD WINAPI StartFaceDetector(LPVOID temp) { int j=0; char **argv1; QApplication a(j,argv1);//add some thread here gui::VisualControl w; t=&w; boost::thread…
Mustansar Fiaz
  • 769
  • 1
  • 5
  • 7
7
votes
2 answers

boost thread and try_join_for gives different output each time

Suppose that I have the following code: #include #include #include int main() { boost::thread thd([]{ std::cout << "str \n"; }); boost::this_thread::sleep_for(boost::chrono::seconds(3)); if…
FrozenHeart
  • 19,844
  • 33
  • 126
  • 242
7
votes
2 answers

How to obtain an exclusive lock *first* and then downgrade to shared without releasing the lock

Stack Overflow has several examples where a function obtains an upgradeable lock first and then obtains exclusive access by upgrading. My understanding is that this can cause deadlocks if not used carefully since two threads may both obtain the…
Elliot Cameron
  • 5,235
  • 2
  • 27
  • 34
7
votes
1 answer

Thread-safe bounded queue hangs in Boost 1.54

The following code for bounded thread-safe queue used to work as expected in Boost 1.49. However, after updating to Boost 1.54 the code no longer runs as expected. Namely, when the buffer is empty (full), the consumer thread (producer thread) is…
Alexey
  • 5,898
  • 9
  • 44
  • 81
7
votes
1 answer

boost::exception_detail::clone_impl >

I need some help with this exception, I am implementing a NPAPI plugin to be able to use local sockets from browser extensions, to do that I am using Firebreath framework. For socket and connectivity I am using Boost asio with async calls and a…
frisco
  • 1,897
  • 2
  • 21
  • 29
7
votes
1 answer

How to make a shared_lock or upgrade_lock in standard C++11?

I am missing very much from the new standard the std::shared_lock template class. In Boost.Thread there is boost::shared_lock, even boost::upgrade_lock exists. Why is that, there is no std::shared_lock and std::unique_lock in C++11? How is it…
Gabor Marton
  • 2,039
  • 2
  • 22
  • 33
7
votes
1 answer

undefined reference to `boost::chrono::system_clock::now()' - Boost, and cpp-netlib

I come here to ask for a fix to a situation that has been frustrating me. A lot. First of all, I'm on Windows, I use MinGW as a compiler (C++). I've been having some problems with getting a program to work with the use of cpp-netlib and SSL (trying…
toficofi
  • 583
  • 6
  • 24
7
votes
2 answers

Boost Thread Cancelling

Can you cancel a Boost Thread as you would a pthread? I'm writing a simple watchdog to terminate worker threads if they crash and there doesn't seem to be a way to simply cancel a thread in the Boost Thread library.
Justin Scheiner
  • 280
  • 4
  • 10
7
votes
1 answer

boost::threads example and heap corruption message

I'm quite new to boost::threads, I read the documentation and but i'm having some trouble applying it in practice, perhaps you can help? First of all, I have taken the time to write a self contained code listing that demonstrates 2 types of behavior…
AlexS
  • 510
  • 2
  • 7
  • 23
6
votes
3 answers

Linking boost::thread

I'm trying to learn something with boost libraries, but I get a problem when I try to compile something that includes boost::threads. I get an error during linking, this is the…
alkz
  • 337
  • 2
  • 7
  • 17
6
votes
1 answer

Boost Thread Exception Handling

I'm trying to throw an exception within a thread and allow the calling process to catch it. However, it seems that this will cause the entire application to crash. See test code attached never prints either exit statement. 1 #include…
Greg
  • 116
  • 1
  • 7
6
votes
3 answers

"Compiler threading support is not turned on."

Normally I can google my way around and find solutions, but not this time. I'm using 64 bit Linux Ubuntu 11.04 to compile a 32 bit windows application. I'm using i586-mingw32msvc-gcc to compile my C++ files. test.cpp: #include…
Mike
  • 2,393
  • 3
  • 25
  • 37
6
votes
1 answer

Debug boost::thread application, high false positive rate

I have programmed a boost::thread application, where I might have some race conditions. I want to debug this program. Therefore I used the following valgrind tools: halgrind drd unfortunately they have a very false positive rate. So with the…
tune2fs
  • 7,605
  • 5
  • 41
  • 57
6
votes
2 answers

How to make class member function as thread function using boost

I am going to write an adapter class. In this class there is an xmlrpc-c server (abyss server). I want to start the server by creating a new thread, and the thread's function is the member function XMLThreadFun(). When I try to use the code below…
Peiti Li
  • 4,634
  • 9
  • 40
  • 57
6
votes
1 answer

Multithreading with C++ API

i am trying to parallel my program using OpenMP and sometimes i feels that i am reaching a dead end. I would like to share variables in a function member that i defined (and initialized) in the class. If i understood correctly, it is not possible…
Eagle
  • 3,362
  • 5
  • 34
  • 46