Rev 1595 | Rev 1601 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 1595 | Rev 1599 | ||
|---|---|---|---|
| Line 21... | Line 21... | ||
| 21 | #include "Manager.h" |
21 | #include "Manager.h" |
| 22 | 22 | ||
| 23 | namespace atom { |
23 | namespace atom { |
| 24 | namespace timer { |
24 | namespace timer { |
| 25 | 25 | ||
| 26 | Manager::Pointer Manager::instance_ |
26 | Manager::Pointer Manager::instance_; |
| 27 | 27 | ||
| 28 | Manager::Manager() : io_service_work_(io_service_) |
28 | Manager::Manager() : io_service_work_(io_service_) |
| 29 | { |
29 | { |
| 30 | 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_)); |
| 31 | this->thread_ = thread.move(); |
31 | this->thread_ = thread.move(); |
| Line 34... | Line 34... | ||
| 34 | Manager::~Manager() |
34 | Manager::~Manager() |
| 35 | { |
35 | { |
| 36 | this->mutex_timers_.lock(); |
36 | this->mutex_timers_.lock(); |
| 37 | this->timers_.clear(); |
37 | this->timers_.clear(); |
| 38 | this->mutex_timers_.unlock(); |
38 | this->mutex_timers_.unlock(); |
| - | 39 | ||
| - | 40 | this->io_service_.stop(); |
|
| 39 | 41 | ||
| 40 | this->thread_.interrupt(); |
42 | this->thread_.interrupt(); |
| 41 | this->thread_.join(); |
43 | this->thread_.join(); |
| 42 | } |
44 | } |
| 43 | 45 | ||
| 44 | Manager::Pointer Manager::Instance() |
46 | Manager::Pointer Manager::Instance() |
| - | 47 | { |
|
| - | 48 | return Manager::instance_; |
|
| - | 49 | } |
|
| - | 50 | ||
| - | 51 | void Manager::Create() |
|
| 45 | { |
52 | { |
| 46 |
|
53 | Manager::instance_ = Manager::Pointer(new Manager()); |
| 47 | } |
54 | } |
| 48 | 55 | ||
| 49 | void Manager::Delete() |
56 | void Manager::Delete() |
| 50 | { |
57 | { |
| 51 | Manager::instance_.reset(); |
58 | Manager::instance_.reset(); |