Hi,
I want to implement a parallel reading-processing-writing line by line based on boost::thread, but the current version has indefinite behaviour : the following test reads a CSV file by filling the read (concurrent) queue, which is simply transferred into the writing queue to be written in an output file (no processing for now).
Pro...
Seems that Boost's shared_mutex is non recursive.. Is there anyway around this? (without re implementing the whole stuff)
...
Is it possible to give a name to a boost::thread so that the debuggers tables and the crash logs can be more readable? How?
...
This is the code to create a thread_group and execute all threads in parallel:
boost::thread_group group;
for (int i = 0; i < 15; ++i)
group.create_thread(aFunctionToExecute);
group.join_all();
This code will execute all threads at once. What I want to do is to execute them all but 4 maximum in parallel. When on is terminated, ano...
Hi.
boost::thread class has a default constructor which gives a "Not-a-thread", so what is
boost::thread t1;
good for? Can I give it a function to execute later in the code?
and another question:
I'm trying to write a little server which has a staged architecture (SEDA), there are a number of worker threads in each stage and the st...
At work we have an MFC Extension DLL that built fine with 1.36 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 file: libboost_thread-vc71-mt-gd-1_35.lib
and
linking to lib file: libboost_thread-vc7...
I have a fairly complex multi threaded application (server) that from time to time will crash due to an assert:
/usr/include/boost/smart_ptr/shared_ptr.hpp:418: T* boost::shared_ptr< <template-parameter-1-1> >::operator->() const [with T = msg::Player]: Assertion `px != 0' failed.
I have been unable to pinpoint the cause and was wonde...
I have an application with a plug-in architecture that is using Boost.Threads as a DLL (specifically, a Mac OS X framework). I am trying to write a plug-in that uses Boost.Threads as well, and would like to link in the library statically. Everything builds fine but the application quickly crashes in my plug-in, deep within the Boost.Thre...
The simplified version of my code looks as follows:
class threadCreator
{
void threadFunction(void){
// use some private data members and do something.
}
void createThread(void){
boost::thread myThread(
boost::bind(&threadCreator::threadFunction,this));
myThread.detach();
}
}
This program wa...
hello,
#include <boost/thread/thread.hpp>
#include <iostream>
void hello()
{
std::cout <<
"Hello world, I'm a thread!"
<< std::endl;
}
int main(int argc, char* argv[])
{
boost::thread thrd(&hello);
thrd.join();
return 0;
}
i ran this program i am getting an error
/usr/include/boost/thread/pthread/mutex.hpp:40: und...
I have a piece of code which uses Boost threads to speed up the calculation, but I need to debug it and want to run them in series, not in parallel. How do I do that?
...
I'm trying to understand some boost code which is causing PC-Lint grief and uses the friend keyword in a way which I didn't think was legal C++ but compiles OK in VS2008.
I thought I understood friend as a way to declare classes and functions. I didn't think it was legal to use on a function definition like this. However, the MSDN page ...
hello
i have a problem with the order of execution of the threads created consecutively.
here is the code.
#include <iostream>
#include <Windows.h>
#include <boost/thread.hpp>
using namespace std;
boost::mutex mutexA;
boost::mutex mutexB;
boost::mutex mutexC;
boost::mutex mutexD;
void SomeWork(char letter, int index)
{
boost:...
In many cases I have classes that act like active objects (have a thread). And to avoid access violations I always have to wait for join in the destructor. Which is usually not a problem.
However imagine a release build with some bug (deadlock, livelock etc.) that causes join() not to return on time or at all, this would cause the enti...
I have a newbie question about Boost::Thread and Mutex.
I would like to start many parallel instances of the following Worker, and all of them write to the same std::vector:
struct Worker {
std::vector<double>* vec;
Worker(std::vector<double>* v) : vec(v) {}
void operator() {
// do some long computation and then add results t...
I have a program with a main thread and a diagnostics thread. The main thread is basically a while(1) loop that performs various tasks. One of these tasks is to provide a diagnostics engine with information about the system and then check back later (i.e. in the next loop) to see if there are any problems that should be dealt with. An...
boost::condition_variable cond;
boost::mutex mut;
void Database::run()
{
boost::unique_lock<boost::mutex> lock(mut);
while(true)
{
while(queries_queue.empty())
cond.wait(lock);
mysqlpp::Query* q = queries_queue.front(); // <<< CRASHES HERE <<<
q->execute();
queries_queue.pop_fron...
I'm trying to create a simple test program using boost::thread, but I get a runtime assertion error.
Here is the code:
#include <iostream>
#include <boost/thread.hpp>
void hello (void) {
std::cout << "Hello, world!" << std::endl;
}
int main (void) {
boost::thread t(&hello);
t.join(); // Fails even without this line
}
T...
I am reading these days about memory fences and barriers as a way to synchronize multithreaded code and avoid code reordering.
I usually develop in C++ under Linux OS and I use boost libs massively but I am not able to find any class related to it. Do you know if memory barrier of fences are present in boost or if there is a way to ach...
I have a question concerning the use of boost::lock_guard (or similar scoped locks) and using variables that should be protected by the lock in a return statement.
How is the order of destroying local objects and copying the return value? How does return value optimization affect this?
Example:
Data Class::GetData()
{
boost::lock_...