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
0
votes
1 answer

Verify a predicate in parallel, return as soon as a thread in a thread pool returns true

I would like to write a function anyElementSatisfiesPredicate that takes in input a predicate function p (that takes in input an object of a given type T and returns a bool) and a std::vector v of objects of type T, and returns true if and only it…
0
votes
1 answer

Boost: How to determine if there are still any producer threads?

I'm using Boost for a multi-producer, single-consumer queue, and want the consumer to quit when queue.empty() && [no more producers]. However, determining when there are no more producers is non-trivial. In particular, I want to avoid any race…
SRobertJames
  • 8,210
  • 14
  • 60
  • 107
0
votes
1 answer

Why use boost disable_interruption when you want to test for interruption_requested()?

A lot of places I see code like this: void threadFunction() { boost::this_thread::disable_interruption disable; while (!boost::this_thread::interruption_requested()) { //do stuff } } For me this looks like I "disable"…
tzippy
  • 6,458
  • 30
  • 82
  • 151
0
votes
2 answers

Using boost multi-threading to run a function in the background

I want to create a multi-threaded C++ program using boost. What I want to do, is to call a function Alpha, which sleeps, and prints out some messages. Whilst that function is being processed, i.e. sleeping, then I want my main program to continue.…
Karnivaurus
  • 22,823
  • 57
  • 147
  • 247
0
votes
3 answers

What is the difference between a joined thread (blocks the calling thread until thread is terminated) and a normal function call

I've recently been looking into thread and thread management and there is something I find confusing this is What is the difference between a joined thread and a normal function call? A thread that has been joined will block the calling thread, is…
0
votes
1 answer

resetting boost::deadline_timer in handler causing crash

Below is sample code of Timer I am using in my server. It is a multithreaded process that process loads of data. Once timer triggers it does some operation on processed data and reset itself for new time class MyTimer { public: …
user1545583
  • 69
  • 1
  • 6
0
votes
1 answer

how to call a function pointer via boost thread

class A { public: int xx(int size) { } public: int xx(int size) { } int yy(int size) { } }; int main() { typedef int (A::*functions)(int); …
Bakkya
  • 447
  • 1
  • 5
  • 8
0
votes
1 answer

One thread in thread_group is not interrupted

I am using boost::thread_group, after sending signal I catch it and sending interrupt_all() on thread_group. Nearly always there is one(!) thread which is not interrupted although he goes through interruption points. I thought that maybe using dual…
galvanize
  • 537
  • 1
  • 5
  • 17
0
votes
1 answer

Cant get boost::thread to work with MSVS2013

i am trying to use Boost:thread for a simple http client i am working on. I cannot get it to work, every other boost lib i am using is working fine. this is the error i am geting: Error 7 error LNK2019: unresolved external symbol "public: class…
Dinari
  • 2,487
  • 13
  • 28
0
votes
2 answers

return value in boost thread without using boost::promise

int xxx() { return 5; } int main() { boost::thread th; th = boost::thread(xxx); th.join(); return 0; } How to catch the value returned by the xxx() method without the use of boost::promise?
Bakkya
  • 447
  • 1
  • 5
  • 8
0
votes
1 answer

How to prevent system sleep with boost::thread

I see SetThreadExecutionState will prevent computer to sleep. With boost::thread, how will I apply this to my software? With disable_interruption?
emrahustun
  • 31
  • 1
  • 5
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
0 answers

boost set name from string

In Linux g++, I do create boost thread like following: boost::thread *td=new boost::thread(function); After I run this program, I always check CPU utilization using top -Hp <-process Id> for example :> top - 13:50:04 up 27 days, 20:51, 4…
Ankur
  • 330
  • 2
  • 8
  • 17
0
votes
0 answers

Error using subclass of class with boost::thread data member

I have created the following class #include #include #include class Messaging { public: Messaging(const std::string& newMessage, unsigned long long maxTimeToDeliver = 12):…
user3731622
  • 4,844
  • 8
  • 45
  • 84
0
votes
1 answer

How to wait for a thread till it has started running

I currently have something like this This is a member of my class boost::shared_ptr my_group; Somewhere else in my code I do this my_group->create_thread( boost::bind( &Myclass::method, this ) ); Now in the above statement is…
Rajeshwar
  • 11,179
  • 26
  • 86
  • 158