boost-thread

Breaking changes in Boost.Thread 3.0.0

强颜欢笑 提交于 2019-12-01 15:11:11
问题 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 if joinable. What does this mean for my existing projects currently using Boost 1.49.0? Do I have to change anything? If yes, what do I have to change exactly? And what happens if I forget to modify one of my existing projects? Will I get compile

Boost.Thread threads not starting on the iPhone/iPad in release builds

不打扰是莪最后的温柔 提交于 2019-12-01 10:49:57
We're writing an iPad app with quite a lot of background processing all of which is written in a set of C++ libraries. These libraries work fine on Linux, Mac and Windows but on the iPad they only work in debug builds. In release builds, it looks like when the first sub-thread is being spun up it either never actually starts, or it doesn't get far enough in its processing to allow the main thread to continue (it isn't very obvious from the debugger if the thread is actually starting or not due to the normal problem of using break points in release builds). Looking in the debugger the main

Running a function on the main thread from a boost thread and passing parameters to that function

余生颓废 提交于 2019-12-01 09:45:58
问题 I have some code running in a boost thread that modifies stuff handled by the main thread which is not working and it makes sense. On android i would have the Handler which is a message queue that would execute my code on the main thread and i can pass whatever parameters i want to this handler. I want to do the same with boost so on my main thread i do the following: boost::thread workerThread(boost::bind(&SomeClass::pollService, this)); My pollService method: SomeClass::pollService() { /

asio::io_service and thread_group lifecycle issue

徘徊边缘 提交于 2019-12-01 07:28:31
问题 Looking at answers like this one, we can do stuff like: boost::asio::io_service ioService; boost::thread_group threadpool; { boost::asio::io_service::work work(ioService); threadpool.create_thread(boost::bind(&boost::asio::io_service::run, ioService)); threadpool.create_thread(boost::bind(&boost::asio::io_service::run, &ioService)); ioService.post(boost::bind(...)); ioService.post(boost::bind(...)); ioService.post(boost::bind(...)); } threadpool.join_all(); However, in my case I want to do

Debug boost::thread application, high false positive rate

隐身守侯 提交于 2019-12-01 05:47:52
I have programmed a boost::thread application, where I might have some race conditions. I want to debug this program. Therefore I used the following valgrind tools: halgrind drd unfortunately they have a very false positive rate. So with the really simple program below valgrind --tool=drd complains about 94 errors, where no should be. So with my complex program I get about 15000 errors. So it is really hard to find the actual error. I could reproduce this behavior with the following boost libraries 1.46.0 and 1.47.0. And with valgrind 3.7.0 SVN and valgrind 3.8.0 SVN. The operating systems I

boost asio asynchronously waiting on a condition variable

烂漫一生 提交于 2019-12-01 04:26:36
Is it possible to perform an asynchronous wait (read : non-blocking) on a conditional variable in boost::asio ? if it isn't directly supported any hints on implementing it would be appreciated. I could implement a timer and fire a wakeup even every few ms, but this is approach is vastly inferior, I find it hard to believe that condition variable synchronization is not implemented / documented. If I understand the intent correctly, you want to launch an event handler, when some condition variable is signaled, in context of asio thread pool? I think it would be sufficient to wait on the

is std::queue thread safe with producer and multiple consumers

99封情书 提交于 2019-12-01 03:13:57
how can I make a queue thread safe? I need to push / pop / front / back and clear. is there something similar in boost? I have one producer and one or more consumer. You must protect access to std::queue . If you are using boost protect it using boost::mutex . Now if you have multiple readers and one writer thread look at boost::shared_lock (for readers) and boost::unique_lock (for writer). However if you will encounter writer thread starvation look at boost::shared_mutex . std::queue is not thread safe if one or more threads are writing. And its interface is not conducive to a thread safe

boost asio asynchronously waiting on a condition variable

坚强是说给别人听的谎言 提交于 2019-12-01 02:03:13
问题 Is it possible to perform an asynchronous wait (read : non-blocking) on a conditional variable in boost::asio ? if it isn't directly supported any hints on implementing it would be appreciated. I could implement a timer and fire a wakeup even every few ms, but this is approach is vastly inferior, I find it hard to believe that condition variable synchronization is not implemented / documented. 回答1: If I understand the intent correctly, you want to launch an event handler, when some condition

boost::thread data structure sizes on the ridiculous side?

感情迁移 提交于 2019-12-01 00:45:16
Compiler: clang++ x86-64 on linux. It has been a while since I have written any intricate low level system code, and I ussualy program against the system primitives (windows and pthreads/posix). So, the in#s and out's have slipped from my memory. I am working with boost::asio and boost::thread at the moment. In order to emulate synchronous RPC against an asynchronous function executor ( boost::io_service with multiple threads io::service::run 'ing where requests are io_serviced::post 'ed), I am using boost synchronization primitives. For curiosities sake I decided to sizeof the primitives.

Possible to stop cin from waiting input?

五迷三道 提交于 2019-11-30 19:03:34
In a graphical application I execute debug commands using the console input. When the console is created a new thread is also created to gather the user commands that handles all that input, the graphical application continues running parallel. I use boost::thread library. It works good so far, however I haven't found a nice solution to stop the execution of this thread. The thread is always waiting for a user input: while(appRunning) { std::cin>>theUserCommand; // ...do stuff } Then when the graphical application ends, it will stop all console functions, in which I include the thread: