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
11
votes
2 answers

boost::lockfree::spsc_queue busy wait strategy. Is there a blocking pop?

So i'm using a boost::lockfree::spec_queue to communicate via two boost_threads running functors of two objects in my application. All is fine except for the fact that the spec_queue::pop() method is non blocking. It returns True or False even if…
easytiger
  • 514
  • 5
  • 15
11
votes
6 answers

java.util.concurrent vs. Boost Threads library

How do the Boost Thread libraries compare against the java.util.concurrent libraries? Performance is critical and so I would prefer to stay with C++ (although Java is a lot faster these days). Given that I have to code in C++, what libraries exist…
user855
  • 19,048
  • 38
  • 98
  • 162
11
votes
2 answers

How to pass function parameters to boost::thread_groups::create_thread()

I am new to Boost.Threads and am trying to understand how to pass function arguments to the boost::thread_groups::create_thread() function. After reading some tutorials and the boost documentations, I understand that it is possible to simply pass…
Mindstorm
  • 443
  • 1
  • 5
  • 12
10
votes
2 answers

Difference between boost::unique_lock and boost::upgrade_lock?

I am new to threading concept in C++ . I Just wanted to know few things: How is a boost::unique_lock different from boost::upgrade_lock? How actually an exclusive ownership differ from upgrade ownership. Maybe one can say exclusive ownership is…
Invictus
  • 4,028
  • 10
  • 50
  • 80
10
votes
1 answer

Possible to stop cin from waiting input?

In a graphical application I execute debug commands using the console input. When the console is created a new thread is also created to gather the user commands that handles all that input, the graphical application continues running parallel. I…
notNullGothik
  • 432
  • 5
  • 20
10
votes
2 answers

boost::thread vs std::thread vs pthread

What are the tradeoffs b/w boost::thread, std::thread (C++11), and pthread for high CPU throughput (read: lots of floating point operations) Linux based applications? When should one implementation be used over the others? The use case here is to…
BigBrownBear00
  • 1,378
  • 2
  • 14
  • 24
10
votes
2 answers

Is boost::io_service::post thread safe?

Is it thread safe to post new handlers from within a handler? I.e. Can threads that called the io_service::run() post new Handlers to the same io_service? Thanks
Johannes Gerer
  • 25,508
  • 5
  • 29
  • 35
10
votes
1 answer

Boost Threads with CLR

Using Visual Studio 2008 and Boost Libraries 1.46.1 I want to compile and link the following with the /CLR flag: #include void run() {} int main(int argc, char *argv[]) { boost::thread t(run); } The first error is…
anve
  • 183
  • 1
  • 11
10
votes
5 answers

c++ boost::thread execute code on main thread?

Is it possible, after calling a boost::thread running some instructions, to come back to main thread ? My code is based around proactor pattern, however a certain function may take some time, so in order not to block the whole program, I'm creating…
TheSquad
  • 7,385
  • 8
  • 40
  • 79
10
votes
2 answers

Pausing a boost::thread for unlimited time

I'm using the boost::thread library (V1.44) to support threads in my C++ project. The user needs to be able to pause the execution of a test loop, that's running in its own thread, for an unlimited amount of time and be able to resume it whenever he…
zitroneneis
  • 1,037
  • 1
  • 12
  • 21
10
votes
2 answers

Example of how to use boost upgradeable mutexes

I have a multithreaded server application that needs mutex locks over some shared memory. The shared memory are basically sTL maps etc. Much of the time I'm just reading from the map. But, I also need to occasionally add to it. e.g. typedef…
hookenz
  • 36,432
  • 45
  • 177
  • 286
10
votes
5 answers

C++ Thread question - setting a value to indicate the thread has finished

Is the following safe? I am new to threading and I want to delegate a time consuming process to a separate thread in my C++ program. Using the boost libraries I have written code something like this: thrd = new…
Hamish
9
votes
1 answer

when to detach or join a boost thread?

I have a method which is fired once every 30 seconds aprox. that I need to have in a thread. I have a method that I can call from outside the class. Something like callThreadedMethod() which creates the thread which itself calls the final…
Pier
  • 10,298
  • 17
  • 67
  • 113
9
votes
1 answer

Is a boost::thread automatically removed from a boost::thread_group when it terminates?

(This question, though similar, didn't really answer my question.) I've had problems with my own "thread group" implementation, and being no closer to solving or even identifying the issue, I'm looking into just using boost::thread_grp. Now, from…
Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
9
votes
5 answers

tr1::hash for boost::thread::id?

I started to use the unordered_set class from the tr1 namespace to speed-up access against the plain (tree-based) STL map. However, I wanted to store references to threads ID in boost (boost::thread::id), and realized that the API of those…
Diego Sevilla
  • 28,636
  • 4
  • 59
  • 87