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

sleep the thread using milliseconds instead of using seconds in C++

I have a boost condition variable which I am using to sleep a thread. boost::condition_variable m_cond; Currently I am using like this in which I am passing the lock and the seconds to which it has to sleep. Currently it will sleep for 10…
AKIWEB
  • 19,008
  • 67
  • 180
  • 294
0
votes
1 answer

How to link against boost_thread on macosx using qt creator?

First off, I don't know much about C++ or QT creator, but I downloaded an old open-source project and I'm trying to compile it using QT Creator and QT 5.1.1 I've gotten passed quite a few errors, but now I'm stuck at boost thread. error:…
Kevin R
  • 8,230
  • 4
  • 41
  • 46
0
votes
0 answers

Simple boost::thread usage crash

This code crash, sometimes : #include struct ThreadData { int t,f; // dummy, but without this it's not crashing int number; }; // this is what each thread does... void MyThreadFunction(ThreadData* threadData) { for…
eranb
  • 89
  • 8
0
votes
2 answers

c++: Why is callback executed but function before callback definition not?

I am wondering why a function doWork() is called without the upper code being exectued. The code is the following: void doWork() { std::cout<<"Hello World>"; sleep(1); doWork(); } .... void foo() { std:cout<<"This is text is never seen in the…
user2212461
  • 3,105
  • 8
  • 49
  • 87
0
votes
1 answer

Behavior of boost::condition_variable::notify_one()

Does the boost::condition_variable::notify_one() function automatically resume execution of the thread it is unblocking or is that undefined and dependent on how the OS schedules the thread? I am not all that familiar with threading and how the OS…
mgoldman
  • 169
  • 11
0
votes
2 answers

"unique_lock has no mutex: Operation not permitted" error when attempting to wait on boost::condition_Variable

I'm trying to use boost::wait_condition to sleep a thread until some new data is available. My function reduces down to this: bool Node::waitForNewData() const { boost::unique_lock(mWasNotifiedMutex); mWasNotified = false; …
Tim MB
  • 4,413
  • 4
  • 38
  • 48
0
votes
1 answer

boost::mutex supports try_lock_for in Visual Studio, but not in Xcode

I'm using Xcode 5.0 and boost 1.54. The following code compiles fine using Visual Studio 2008 Sp1, but does not compile in Xcode: template bool try_lock_for(const boost::chrono::duration &_rel_time) { …
Arno Duvenhage
  • 1,910
  • 17
  • 36
0
votes
0 answers

Expected identifier before 'float' error; boost/thread

I'm experiencing very wierd error when trying to build my program with Boost thread.hpp included (ver. 1.54, but tried also lower): /home/seweryn/boost/include/boost/functional/hash/detail/float_functions.hpp:78: error: expected…
TomaszP
  • 3
  • 2
0
votes
1 answer

What is the difference between passing a loop counter or range-declaration to a thread by reference?

#include #include #include #include "boost/thread.hpp" using boost::thread; using std::vector; using std::unique_ptr; class ThreadPool { public: ThreadPool(int size) : max_size_(size) {} ~ThreadPool() { …
user334856
0
votes
0 answers

Using MATLAB Compiler Runtime on Chinese Windows box

Calling Initialize() or InitializeWithHandlers() is hanging when my (non-localized) software is used on a Windows 7 system with Chinese locale. We're using MCR v7.15. I took a dump of the process and it appears to be a deadlock…
Thomas
  • 3,348
  • 4
  • 35
  • 49
0
votes
3 answers

Is it safe to call a signal function of a widget class in Qt from multiple threads in C++?

Is it safe to call widget's signal function from multiple threads simultaneously? Will Qt use some kind of internal mutex to provide security of its own data structures when multiple threads call some widget's signal simultaneously? As i understand,…
pavelkolodin
  • 2,859
  • 3
  • 31
  • 74
0
votes
1 answer

Thread pool Implementation using Boost::thread class

I want to implement thread pool using boost::thread class. I am able to create the threads using below line. boost::thread Consumer_1(consume); where consumer_1 is thread and consume is the function bound to it. Above statement starts the thread…
Codelearner
  • 241
  • 2
  • 3
  • 16
0
votes
2 answers

compiler error on calling boost::bind() inside boost::thread constructor

I am currently writing a firebreath C++ NPAPI plugin, and i an trying to invoke a boost::thread from inside the plugin. The platform i am building it is Ubuntu Linux 13.04. Here is the skeleton of the class declaration and relevant member function…
0
votes
2 answers

Exception thrown using boost thread library

I have the following code to run a timed thread: // Method to invoke a request with a timeout. bool devices::server::CDeviceServer::invokeWithTimeout(CDeviceClientRequest& request, …
Marcus MacWilliam
  • 602
  • 1
  • 6
  • 24
0
votes
1 answer

Boost condition variable usage

I'm trying to implement a producer-consumer pattern. I did my homework but still couldn't be sure about it. The implementation is as follows: boost::mutex m_mutex; boost::container::deque m_buffer; boost::condition_variable fifo_loaded; T…
Murat Şeker
  • 1,651
  • 1
  • 16
  • 29