Rev 1625 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 1625 | Rev 1939 | ||
|---|---|---|---|
| Line 17... | Line 17... | ||
| 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 | * |
18 | * |
| 19 | */ |
19 | */ |
| 20 | 20 | ||
| 21 | #include "IoService.h" |
21 | #include "IoService.h" |
| - | 22 | ||
| - | 23 | #include <iostream> |
|
| 22 | 24 | ||
| 23 | namespace atom { |
25 | namespace atom { |
| 24 | namespace common { |
26 | namespace common { |
| 25 | 27 | ||
| 26 | IoService::IoService() : io_service_work_(io_service_) |
28 | IoService::IoService() : io_service_work_(io_service_) |
| 27 | { |
29 | { |
| 28 | boost::thread thread(boost::bind(&boost::asio::io_service::run, &this->io_service_)); |
30 | boost::thread thread(boost::bind(&boost::asio::io_service::run, &this->io_service_)); |
| 29 | this->thread_ = thread.move(); |
31 | this->thread_ = thread.move(); |
| 30 | 32 | ||
| 31 | this->tracker_ = TrackerPointer(new char); |
33 | this->tracker_ = TrackerPointer(new char); |
| 32 | } |
34 | } |
| 33 | 35 | ||
| 34 | IoService::~IoService() |
36 | IoService::~IoService() |
| 35 | { |
37 | { |
| - | 38 | std::cout << "~IoService() called!" << std::endl; |
|
| - | 39 | ||
| - | 40 | this->Stop(); |
|
| - | 41 | ||
| - | 42 | std::cout << "~IoService() called done!" << std::endl; |
|
| - | 43 | } |
|
| - | 44 | ||
| - | 45 | boost::asio::io_service& IoService::GetIoService() |
|
| - | 46 | { |
|
| - | 47 | return this->io_service_; |
|
| - | 48 | } |
|
| - | 49 | ||
| - | 50 | void IoService::Stop() |
|
| - | 51 | { |
|
| - | 52 | std::cout << "Stop() called!" << std::endl; |
|
| - | 53 | ||
| 36 | this->tracker_.reset(); |
54 | this->tracker_.reset(); |
| 37 | 55 | ||
| 38 | this->io_service_.stop(); |
56 | this->io_service_.stop(); |
| 39 | 57 | ||
| 40 |
|
58 | //this->thread_.interrupt(); |
| 41 | this->thread_.join(); |
59 | this->thread_.join(); |
| 42 | } |
- | |
| 43 | 60 | ||
| 44 |
|
61 | std::cout << "Stop() called done!" << std::endl; |
| 45 | { |
- | |
| 46 | return this->io_service_; |
- | |
| 47 | } |
62 | } |
| 48 | 63 | ||
| 49 | }; // namespace common |
64 | }; // namespace common |
| 50 | }; // namespace atom |
65 | }; // namespace atom |