boost-thread

Memory leak caused by a wrong usage of scoped_lock ?

I have a memory leak, and I guess it's caused by a wrong usage of scoped_lock (Boost). I however don't manage to find the exact problem, and I do believe that the way the code has been written is not completely right neither. The code is in this class there: http://taf.codeplex.com/SourceControl/changeset/view/31767#511225 The main imp...

C++ boost::thread and automatically locking containers

Is there a way to automatically lock an STL container on access, without having to lock and release around it? ...

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<int()> th_func = boost::bind(&Worker::Do, &worker); boost::thread th(th_func); th.join(); My quest...

java.util.concurrent vs. Boost Threads library

Hi, How does 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 to make threading easy and less error prone. I have heard recently that as of JDK...

boost thread and join

Hi, I've got this test case here that compiles with g++ theFile.cc -lboost_thread. When running the program it seems to be hanging at the join command. I'm not exactly sure why. It's like the interrupt_point() function isn't getting the join request from the main thread. #include <iostream> #include <stdio.h> #include <signal.h> #inclu...

c++ boost::thread sleep()

Hi, I am currently working on a small wrapper class for boost thread but I dont really get how the sleep function works, this is what I have got so far: BaseThread::BaseThread(){ thread = boost::thread(); bIsActive = true; } BaseThread::~BaseThread(){ join(); } void BaseThread::join(){ thread.join(); } void BaseT...

Controlling access to output in multi-threaded applications

I have an application that creates a job queue, and then multiple threads execute the jobs. By execute them, I mean they call system() with the job string. The problem is that output to stdout looks like the output at the bottom of the question. I would like each application run to be separated, so the output would look like: flac 1.2...

How might one create an extra worker thread for a single threaded GUI application?

I am currently developing new features for an existing VCL application. The application creates charts and static images using a thirdparty package called TeeChart. There is one instance where I have to load in 2 million data points to create a static image chart. However, this takes a while to load and the user can't do anything in the ...

Static Compile of Thread Example

I compiled the Boost C++ libraries as follows: bjam install variant=release link=static threading=multi runtime-link=static No errors. Then I compiled the following source: #include <boost/thread/thread.hpp> #include <iostream> #define BOOST_THREAD_NO_LIB void hello() { std::cout << "Hello world, I'm a thread!" << std::endl; } i...

Boost threads coring on startup.

I have a program that brings up and tears down multiple threads throughout its life. Everything works great for awhile, but eventually, I get the following core dump stack trace. #0 0x009887a2 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2 #1 0x007617a5 in raise () from /lib/tls/libc.so.6 #2 0x00763209 in abort () from /lib/tls/lib...

Select mutex or dummy mutex at runtime

I have a class that is shared between several projects, some uses of it are single-threaded and some are multi-threaded. The single-threaded users don't want the overhead of mutex locking, and the multi-threaded users don't want to do their own locking and want to be able to optionally run in "single-threaded mode." So I would like to ...

Tomcat crashes if make mutlithreaded native call using Jace JNI

I am using Netbeans to build a java web project (tomcat 6.02 based) which loads a c++ native dll. I am using Jace library which wraps JNI. In my java code I have a static callback function which I call from c++ code. I am trying to invoke this callback in a new thread using boost.Thread but tomcat just dies without any message or crash ...

ReadWrite lock using Boost.Threads (how to convert this simple class)

I am porting some code from windows to Linux (Ubuntu 9.10). I have a simple class (please see below), which uses windows functions to implement simple mutex locking. I want to use Boost.Threads to reimplement this, but that library is new to me. Can someone point out the changes I need to make to the class below, in order tomuse Boost.T...

boost::thread_group - is it ok to call create_thread after join_all?

Hi, I have the following situation: I create a boost::thread_group instance, then create threads for parallel-processing on some data, then join_all on the threads. Initially I created the threads for every X elements of data, like so: // begin = someVector.begin(); // end = someVector.end(); // batchDispatcher = boost::function<void...

Odd C++ member function declaration syntax: && qualifier.

From Boost::Thread: template <typename R> class shared_future { ... // move support shared_future(shared_future && other); shared_future(unique_future<R> && other); shared_future& operator=(shared_future && other); shared_future& operator=(unique_future<R> && other); ... } What on earth are those double-ampersands ? I went over "BS Th...

How do I know which thread called a method

I have a threadSafe method that gets called by multiple threads. Is there a way to know which thread called it? ...

Scintilla and thread safety

I'm using the Scintilla edit control on Windows (Win32, C/C++) . The control is created in WndProc. I have a second thread, created with Boost.Thread, that act as a spell checker and marks with red squiggle incorrectly spelled words. Therefore, I have two threads altering the content of the Scintilla control. At first, the program was ...

Does boost::asio::deadline_timer use a thread for each timer?

I have a list of items that I need to update on different intervals. The list can grow to be thousands of items long. Each item could potentially have a different interval. If I create one timer per item, am I going to saturate the system with threads? I was thinking it might be better to create one timer equal to the smallest interval i...

Multi-Threaded MPI Process Suddenly Terminating

Hey all - I'm writing an MPI program (Visual Studio 2k8 + MSMPI) that uses Boost::thread to spawn two threads per MPI process, and have run into a problem I'm having trouble tracking down. When I run the program with: mpiexec -n 2 program.exe, one of the processes suddenly terminates: job aborted: [ranks] message [0] terminated [1] ...

C++ threaded class design from non-threaded class

I'm working on a library doing audio encoding/decoding. The encoder shall be able to use multiple cores (i.e. multiple threads, using boost library), if available. What i have right now is a class that performs all encoding-relevant operations. The next step i want to take is to make that class threaded. So i'm wondering how to do this....