| 101 | } |
| 102 | |
| 103 | unique_ptr<Notifier> NotifierPool::Get() { |
| 104 | lock_guard<mutex> lock_guard(impl_->lock); |
| 105 | |
| 106 | unique_ptr<Notifier> notifier = nullptr; |
| 107 | if (!impl_->notifiers.empty()) { |
| 108 | notifier = move(impl_->notifiers.front()); |
| 109 | impl_->notifiers.pop(); |
| 110 | |
| 111 | } else { |
| 112 | notifier.reset(new Notifier()); |
| 113 | if (!notifier->Init()) notifier = nullptr; |
| 114 | } |
| 115 | assert(notifier != nullptr); |
| 116 | |
| 117 | return notifier; |
| 118 | } |
| 119 | |
| 120 | void NotifierPool::Put(unique_ptr<Notifier> ¬ifier) { |
| 121 | lock_guard<mutex> lock_guard(impl_->lock); |