boost-thread

boost::thread and creating a pool of them!

本秂侑毒 提交于 2019-12-10 18:43:16
问题 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 stages are connected with event queues. when i create the pool with 4 worker threads using boost::thread_group like this: (I've removed the condition variable on the

Communication b/w two threads over a common datastructure. Design Issue

一曲冷凌霜 提交于 2019-12-10 17:28:33
问题 I currently have two threads a producer and a consumer. The producer is a static methods that inserts data in a Deque type static container and informs the consumer through boost::condition_variable that an object has been inserted in the deque object . The consumer then reads data from the Deque type and removes it from the container.The two threads communicate using boost::condition_variable Here is an abstract of what is happening. This is the code for the consumer and producer //Static

Is there a way to set thread affinity to a processor core with the boost thread library?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-10 16:49:39
问题 And would it be a good idea to do so if I needed the processor cores running on 100% for a dozen seconds or would I get better performance if I let the system decide how to handle the threads? What I need is fast execution and I'm worried the system might spend a few seconds before using all the cores, but I haven't found any way of doing this with boost thread. 回答1: You'll first need to call the get_native_handle member function then pass the obtained handle to a platform specific function

boost condition variable issue

£可爱£侵袭症+ 提交于 2019-12-10 13:57:26
问题 The following minimal code sample of a larger program sends commands from client threads to an asio io_service object. The io_service object (in the Ios class) is being run with one thread. When the command is sent the client thread waits until it is notified by the Ios object (via Cmd::NotifyFinish()) that it is completed. This sample seems to run on Linux Ubuntu 11.04 with boost 1.46 fine but on Windows 7 boost 1.46 it asserts. I suspect it is something to do with the lock in Cmd:

Boost threads coring on startup

梦想与她 提交于 2019-12-10 11:58:14
问题 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/libc.so.6 #3 0x003ec1bb in __gnu_cxx::__verbose_terminate_handler () from /usr/lib/libstdc++.so.6 #4 0x003e9ed1 in __cxa_call_unexpected () from /usr/lib/libstdc++.so

boost thread and process cleanup on windows

两盒软妹~` 提交于 2019-12-10 11:35:18
问题 In my program I have a static object that creates a boost::thread. The thread is supposed to run until program termination, but it shouldn't be terminated in random state, so I implemented controled thread termination in this static object's destructor. The problem is that when main() terminates my thread is terminated before the destructor is called. Now the question: is it possible to prevent the thread to be destroyed? Or at least delay it, so that it happens after the destructor is called

Multiprocessor Boost::Thread? All threads running on one processor

梦想的初衷 提交于 2019-12-10 06:36:33
问题 I have a embarrassingly parallel problem that I want to execute on multiple processors. I had supposed that boost::thread would automatically send new threads to new processors, but all of them are executing on the same core as the parent process. Is it possible to get each thread to run on a different processor, or do I need something like MPI? My suspicion is that boost::thread is simply not a multi-processor tool, that I'm asking it to do something it's not designed for. EDIT: my question

How to obtain an exclusive lock *first* and then downgrade to shared without releasing the lock

ⅰ亾dé卋堺 提交于 2019-12-10 04:57:57
问题 Stack Overflow has several examples where a function obtains an upgradeable lock first and then obtains exclusive access by upgrading. My understanding is that this can cause deadlocks if not used carefully since two threads may both obtain the upgradeable/shared lock and then both attempt to upgrade, at which point neither can proceed because the other has a shared lock. What I want is to obtain the exclusive lock first and then downgrade to a shared lock without releasing the lock

undefined reference to `boost::chrono::system_clock::now()' - Boost, and cpp-netlib

孤人 提交于 2019-12-10 03:56:23
问题 I come here to ask for a fix to a situation that has been frustrating me. A lot. First of all, I'm on Windows, I use MinGW as a compiler (C++). I've been having some problems with getting a program to work with the use of cpp-netlib and SSL (trying to POST to a https site). I believe everything is in order except this one error that keeps evading me. C:\boost_1_50_0\boost_1_50_0\stage\lib\libboost_thread-mgw46-mt-1_50.a(thread.o):thread.cpp|| undefined reference to 'boost::chrono::system

when to detach or join a boost thread?

泪湿孤枕 提交于 2019-12-09 16:38:54
问题 I have a method which is fired once every 30 seconds aprox. that I need to have in a thread. I have a method that I can call from outside the class. Something like callThreadedMethod() which creates the thread which itself calls the final threadedMethod. These are methods of MyClass void callThreadedMethod(){ mThread = boost::shared_ptr<boost::thread>(new boost::thread(&MyClass::threadedMethod, this)); } void threadedMethod(){ //more code NOT inside a while loop } So do I have to detach