boost-thread

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

孤街浪徒 提交于 2019-11-30 18:11:14
问题 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

Boost Threads with CLR

落花浮王杯 提交于 2019-11-30 08:59:32
Using Visual Studio 2008 and Boost Libraries 1.46.1 I want to compile and link the following with the /CLR flag: #include <boost/thread/thread.hpp> void run() {} int main(int argc, char *argv[]) { boost::thread t(run); } The first error is about a forward-declared dummy-struct in boost::thread. This post works around this by declaring: namespace boost { struct thread::dummy {}; } Sure, I now can compile, but then I get the linker warning Warning 1 warning LNK4248: unresolved typeref token (0100001F) for 'boost.detail.win32._SECURITY_ATTRIBUTES'; image may not run Running the application

why is string not declared in scope

只谈情不闲聊 提交于 2019-11-30 08:22:05
I have the following code: #include <string> #include <boost/thread/tss.hpp> static boost::thread_specific_ptr<string> _tssThreadNameSptr; I get the following error g++ -c -I$BOOST_PATH tssNaming.h tssNaming.h:7: error: 'string' was not declared in this scope But I am including string in my #include . You have to use std::string since it's in the std namespace. string is in the std namespace. You have the following options: Write using namespace std; after the include and enable all the std names: then you can write only string on your program. Write using std::string after the include to

CMake and Boost

自作多情 提交于 2019-11-30 05:26:14
I've searched and found out that a lot of people have the same problem, but no solution exists. I'm using CMake to generate Makefiles for MinGW and when compiling I'm getting an error: CMakeFiles\boosttest.dir/objects.a(main.cpp.obj):main.cpp:(.text+0x5e): undefined reference to `_imp___ZN5boost6thread4joinEv' CMakeFiles\boosttest.dir/objects.a(main.cpp.obj):main.cpp:(.text+0x71): undefined reference to `_imp___ZN5boost6threadD1Ev' CMakeFiles\boosttest.dir/objects.a(main.cpp.obj):main.cpp:(.text+0x88): undefined reference to `_imp___ZN5boost6threadD1Ev' This seems to be a linking problem, I

Possible to stop cin from waiting input?

ぐ巨炮叔叔 提交于 2019-11-30 03:51:25
问题 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

Is there a bug in the boost asio HTTP Server 3 example or boost bug?

爷,独闯天下 提交于 2019-11-29 15:46:55
boost library version 1.53 Debian Linux 6.0 ( Linux 2.6.32-5-amd64 on x86_64 ) It is hard to test own software when valgrind log contains lots of warnings. So with no changes I built the HTTP server3 example and run it under the Valgrind. Take a look, please. Did I miss something? valgrind --tool=helgrind --log-file=valgrind.log ./server3 0.0.0.0 83 5 /root/server3 Here is the Helgrind log (edited to 30000 body characters limit, full log http://pastebin.com/Vkbr9vsA ): Helgrind, a thread error detector Copyright (C) 2007-2012, and GNU GPL'd, by OpenWorks LLP et al. Using Valgrind-3.9.0.SVN and

Why is destructor of boost::thread detaching joinable thread instead of calling terminate() as standard suggests?

。_饼干妹妹 提交于 2019-11-29 13:40:56
问题 According to the draft C++0x standard, this code: void simplethread() { boost::thread t(someLongRunningFunction); // Commented out detach - terminate() expected. // t.detach(); } ... should result in an terminate() call, but in current (boost 1.46.1) implementation of boost threads it doesn't, thread simply gets detached in destructor and continues on. My question is: why? I thought boost::thread is as much inline with draft standard as it gets. Is there a design reason for this? Will it be

Boost Threads with CLR

隐身守侯 提交于 2019-11-29 13:26:50
问题 Using Visual Studio 2008 and Boost Libraries 1.46.1 I want to compile and link the following with the /CLR flag: #include <boost/thread/thread.hpp> void run() {} int main(int argc, char *argv[]) { boost::thread t(run); } The first error is about a forward-declared dummy-struct in boost::thread. This post works around this by declaring: namespace boost { struct thread::dummy {}; } Sure, I now can compile, but then I get the linker warning Warning 1 warning LNK4248: unresolved typeref token

Getting return value from a boost::threaded member function?

荒凉一梦 提交于 2019-11-29 04:29:18
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 question is, how do I get the return value of Worker::Do? Thanks in advance. I don't think you can get the return value. Instead, you can store the value as a member of Worker: class Worker{ public: void Do(){ int ret = 100; // do stuff m_ReturnValue = ret; } int m_ReturnValue; } And use

thread destructors in C++0x vs boost

Deadly 提交于 2019-11-29 03:41:36
These days I am reading the pdf Designing MT programs . It explains that the user MUST explicitly call detach() on an object of class std::thread in C++0x before that object gets out of scope. If you don't call it std::terminate() will be called and the application will die. I usually use boost::thread for threading in C++. Correct me if I am wrong but a boost::thread object detaches automatically when it get out of scope. Is seems to me that the boost approach follow a RAII principle and the std doesn't. Do you know if there is some particular reason for this? This is indeed true, and this