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

How to sleep with boost::chrono?

Examples of boost::this_thread::sleep() seem to use objects of boost::posix_time::milliseconds. I've tried that and it works, but I am using boost::chrono for checking the system clock etcetera. It seems to me I should be able to pass sleep() a…
2NinerRomeo
  • 2,687
  • 4
  • 29
  • 35
8
votes
5 answers

Compiling C++ source file using Boost.Thread

I am trying to learn how to use the C++ Boost.Thread library. I have installed the Boost libraries on my Ubuntu 11.10 system. I am following the book "The Boost C++ Libraries" by Schaling - specifically example 6.1 on page 66. I am trying to…
TJB
  • 3,493
  • 4
  • 23
  • 20
8
votes
1 answer

How to get the exception reported to boost::future?

If I use Boost futures, and the future reports true to has_exception(), is there any way to retrieve that exception? For example, here is the following code: int do_something() { ... throw some_exception(); ... …
petersohn
  • 11,292
  • 13
  • 61
  • 98
8
votes
8 answers

Is it dangerous to read global variables from separate threads at potentially the same time?

So I'm writing this neat little program to teach myself threading, I'm using boost::thread and C++ to do so. I need the main thread to communicate with the worker thread, and to do so I have been using global variables. It is working as expected,…
ch0l1n3
  • 275
  • 3
  • 9
8
votes
1 answer

Boost cannot find future::then from demo

I wanted to try boost future then, I have boost 1.55 installed and included in make file and I wanted to try official demo #define BOOST_THREAD_PROVIDES_FUTURE #include using namespace boost; int main() { future
PaolaJ.
  • 10,872
  • 22
  • 73
  • 111
8
votes
1 answer

Porting C++11 std::thread to boost::thread compile issues

I'm trying to port C++11 std::thread code to VC9 (VS 2008) using boost::thread. The 'equivalent' C++11 code below compiles fine on msvc12: #include #include #include #include #include void…
hhbilly
  • 1,265
  • 10
  • 18
8
votes
0 answers

How do I catch a boost::thread_interrupted exception in a worker thread?

I am having trouble catching an interrupt in a worker thread. There are numerous boost thread interrupt posts on here but, they seem to be silly mistakes (which I'm sure my question is too), or something that didn't help Boost thread_interrupted…
Andre
  • 115
  • 1
  • 7
8
votes
5 answers

Getting return value from a boost::threaded member function?

I have a worker class like the one below: class Worker{ public: int Do(){ int ret = 100; // do stuff return ret; } } It's intended to be executed with boost::thread and boost::bind, like: Worker worker; boost::function
He Shiming
  • 5,710
  • 5
  • 38
  • 68
8
votes
1 answer

Join a specific boost thread

I m creating about 300 boost threads in a process. Is there any way to join a specific thread based on the thread id ?
sri
  • 165
  • 1
  • 7
8
votes
3 answers

Threads in C, C++, C++0x, pthread and boost

A question about threads in C/C++... C++0x syntax #include void dummy() {} int main(int, char*[]) { std::thread x(dummy); std::thread y(dummy); ... return 0; } How many threads are there? Two (x and y) or three (x, y and…
Giovanni Funchal
  • 8,934
  • 13
  • 61
  • 110
8
votes
2 answers

Breaking changes in Boost.Thread 3.0.0

In the release notes of version 1.50.0 of the Boost libraries I noted two breaking changes (see here): #6266 Breaking change: thread destructor should call terminate if joinable. #6269 Breaking change: thread move assignment should call terminate…
Robert Hegner
  • 9,014
  • 7
  • 62
  • 98
7
votes
1 answer

Boost thread and UPX compression == not valid win32 application?

When I just declare boost::thread t1, t2; in my program and then compress .exe file with UPX, the compression succeeds. But when I try to launch the compressed exe, Windows tells me that it's "not valid win32 application". There is a bug report…
Sergey
  • 19,487
  • 13
  • 44
  • 68
7
votes
2 answers

Upgrade of BOOST 1.35 to 1.43 causes linker error with __pRawDllMain (mfc related)

At work we have an MFC Extension DLL that built fine with 1.35 but when built with 1.43 causes the following error: error LNK2005: __pRawDllMain already defined in ApObs.obj If I activate BOOST_LIB_DIAGNOSTIC the old build lists: linking to lib…
Peter Nimmo
  • 1,045
  • 2
  • 12
  • 25
7
votes
1 answer

Problems regarding Boost::Python and Boost::Threads

Me and a friend are developing an application which uses Boost::Python. I have defined an interface in C++ (well a pure virtual class), exposed through Boost::Python to the users, who have to inherit from it and create a class, which the application…
Fabzter
  • 505
  • 5
  • 16
7
votes
3 answers

Boost.Thread wakes up too late in 1.58

I have an application that needs to do work within certain windows (in this case, the windows are all 30 seconds apart). When the time is not within a window, the time until the middle of the next window is calculated, and the thread sleeps for that…
Scott M
  • 482
  • 3
  • 14