Last active
October 11, 2015 01:38
-
-
Save snaewe/3782446 to your computer and use it in GitHub Desktop.
Run boost::asio::io_service::run in a thread
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// -*- c++ -*- | |
// compile with: "g++ -D_WIN32_WINNT=0x501 run_iosvc_in_thread.cpp -lboost_thread -lboost_system -lwsock32 -o run_iosvc_in_thread" | |
#include <boost/asio.hpp> | |
#include <boost/thread.hpp> | |
#include <boost/bind.hpp> | |
#include <boost/scoped_ptr.hpp> | |
int main() | |
{ | |
boost::scoped_ptr<boost::asio::io_service> m_ioServicePtr(new boost::asio::io_service); | |
boost::scoped_ptr<boost::thread> m_logThread(new boost::thread( boost::bind( &boost::asio::io_service::run, m_ioServicePtr.get() ))); | |
m_logThread->join(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment