boost-thread

Why would a friend function be defined as part of a struct - boost thread_data?

旧城冷巷雨未停 提交于 2019-12-23 18:07:56
问题 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 is very specific: Friend functions can be defined inside class declarations. These functions are inline functions, and like member inline functions they behave

What is the difference between poll and run?

荒凉一梦 提交于 2019-12-23 12:43:12
问题 Does anyone have an example illustrating the difference between boost::asio::io_service::poll and boost::asio::io_service::run ? More specifically what is the difference between calling join_all() on a thread_group executing run() and on another one executing poll() ? Do both guarantee that all events have finished? In the documentation available at http://www.boost.org/doc/libs/1_53_0/doc/html/boost_asio/reference/io_service/run/overload1.html, it is said: The poll() function may also be

Using boost::asio::io_service::post()

冷暖自知 提交于 2019-12-23 12:14:31
问题 First i asked this Running a function on the main thread from a boost thread and passing parameters to that function so now i am trying this: The following is a console c++ project where i perfectly simulated my big project TestServicePost.cpp #include "stdafx.h" #include "SomeClass.h" int _tmain(int argc, _TCHAR* argv[]) { SomeClass* s = new SomeClass(); while(true) { s->update(); } return 0; } SomeClass.h #include <boost/thread.hpp> #include <boost/asio.hpp> #include <queue> class

Using boost::thread_specific_ptr in a non-boost thread

て烟熏妆下的殇ゞ 提交于 2019-12-22 05:52:35
问题 I'm reading the documentation section for boost::thread_specific_ptr, and trying to parse this paragraph: Note: on some platforms, cleanup of thread-specific data is not performed for threads created with the platform's native API. On those platforms such cleanup is only done for threads that are started with boost::thread unless boost::on_thread_exit() is called manually from that thread. First, what is probably a pedantic point: I assume they meant to say boost::this_thread::at_thread_exit(

Do we need multiple io_service per thread for threaded boost::asio server with a single acceptor

£可爱£侵袭症+ 提交于 2019-12-22 04:33:14
问题 I am not much experienced in boost::asio . I've some pretty basic questions. Do I need to have a different io_service , and a different socket under a different thread but one single acceptor , to process a client in a threaded server ? I believe I must have a different socket for a new client. But if all threads use the same io_service would it be parallel ? I was going through http://en.highscore.de/cpp/boost/index.html in asio section which says I need to have different io_services in

How to use boost::bind with non-copyable params, for example boost::promise?

Deadly 提交于 2019-12-21 07:57:23
问题 Some C++ objects have no copy constructor, but have move constructor. For example, boost::promise. How can I bind those objects using their move constructors ? #include <boost/thread.hpp> void fullfil_1(boost::promise<int>& prom, int x) { prom.set_value(x); } boost::function<void()> get_functor() { // boost::promise is not copyable, but movable boost::promise<int> pi; // compilation error boost::function<void()> f_set_one = boost::bind(&fullfil_1, pi, 1); // compilation error as well boost:

How to use boost::bind with non-copyable params, for example boost::promise?

本小妞迷上赌 提交于 2019-12-21 07:57:07
问题 Some C++ objects have no copy constructor, but have move constructor. For example, boost::promise. How can I bind those objects using their move constructors ? #include <boost/thread.hpp> void fullfil_1(boost::promise<int>& prom, int x) { prom.set_value(x); } boost::function<void()> get_functor() { // boost::promise is not copyable, but movable boost::promise<int> pi; // compilation error boost::function<void()> f_set_one = boost::bind(&fullfil_1, pi, 1); // compilation error as well boost:

What does boost::thread sleep() do?

安稳与你 提交于 2019-12-21 07:27:21
问题 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 BaseThread::sleep(uint32 _msecs){ if(bIsActive) boost::this_thread::sleep(boost::posix_time::milliseconds(_msecs)); } This is how I implemented it so far but I dont really understand how the

Boost.Thread throws bad_alloc exception in VS2010

限于喜欢 提交于 2019-12-20 03:57:07
问题 Upon including <boost/thread.hpp> I get this exception: First-chance exception at 0x7c812afb in CSF.exe: Microsoft C++ exception: boost::exception_detail::clone_impl<boost::exception_detail::bad_alloc_> at memory location 0x0012fc3c.. First-chance exception at 0x7c812afb in CSF.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000.. I can't catch it, breaking at the memory location brings me to kernel32.dll and at this point I cannot say what's going on but it appears that the

PortAudio real-time audio processing for continuous input stream

拈花ヽ惹草 提交于 2019-12-20 02:32:47
问题 I am using PortAudio to implement a real-time audio processing. My primary task is to acquire data from mic continuously and provide 100 samples for processing (each FRAME = 100 samples at a time) to some other processing thread. Here is my callback collecting 100 samples each time on a continuous basis - static int paStreamCallback( const void* input, void* output, unsigned long samplesPerFrame, const PaStreamCallbackTimeInfo* timeInfo, PaStreamCallbackFlags statusFlags, void* userData ) {