Rev 1625 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | SVN | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 1598 | runge | 1 | /* |
| 2 | * |
||
| 3 | * Copyright (C) 2010 Mattias Runge |
||
| 4 | * |
||
| 5 | * This program is free software; you can redistribute it and/or modify |
||
| 6 | * it under the terms of the GNU General Public License as published by |
||
| 7 | * the Free Software Foundation; either version 2 of the License, or |
||
| 8 | * (at your option) any later version. |
||
| 9 | * |
||
| 10 | * This program is distributed in the hope that it will be useful, |
||
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
| 13 | * GNU General Public License for more details. |
||
| 14 | * |
||
| 15 | * You should have received a copy of the GNU General Public License along |
||
| 16 | * with this program; if not, write to the Free Software Foundation, Inc., |
||
| 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
||
| 18 | * |
||
| 19 | */ |
||
| 20 | |||
| 21 | #include "IoService.h" |
||
| 22 | |||
| 1939 | runge | 23 | #include <iostream> |
| 24 | |||
| 1598 | runge | 25 | namespace atom { |
| 26 | namespace common { |
||
| 27 | |||
| 28 | IoService::IoService() : io_service_work_(io_service_) |
||
| 29 | { |
||
| 1939 | runge | 30 | boost::thread thread(boost::bind(&boost::asio::io_service::run, &this->io_service_)); |
| 31 | this->thread_ = thread.move(); |
||
| 1598 | runge | 32 | |
| 1939 | runge | 33 | this->tracker_ = TrackerPointer(new char); |
| 1598 | runge | 34 | } |
| 35 | |||
| 36 | IoService::~IoService() |
||
| 37 | { |
||
| 1939 | runge | 38 | std::cout << "~IoService() called!" << std::endl; |
| 39 | |||
| 40 | this->Stop(); |
||
| 1598 | runge | 41 | |
| 1939 | runge | 42 | std::cout << "~IoService() called done!" << std::endl; |
| 1598 | runge | 43 | } |
| 1625 | runge | 44 | |
| 45 | boost::asio::io_service& IoService::GetIoService() |
||
| 46 | { |
||
| 1939 | runge | 47 | return this->io_service_; |
| 1625 | runge | 48 | } |
| 1939 | runge | 49 | |
| 50 | void IoService::Stop() |
||
| 51 | { |
||
| 52 | std::cout << "Stop() called!" << std::endl; |
||
| 53 | |||
| 54 | this->tracker_.reset(); |
||
| 55 | |||
| 56 | this->io_service_.stop(); |
||
| 57 | |||
| 58 | //this->thread_.interrupt(); |
||
| 59 | this->thread_.join(); |
||
| 60 | |||
| 61 | std::cout << "Stop() called done!" << std::endl; |
||
| 62 | } |
||
| 63 | |||
| 1598 | runge | 64 | }; // namespace common |
| 65 | }; // namespace atom |