| 23 | return **sm_pool; |
| 24 | } |
| 25 | CompNode::Event* EventPool::alloc(CompNode cn) { |
| 26 | CompNode::EventPool* pool; |
| 27 | { |
| 28 | MGB_LOCK_GUARD(m_lock); |
| 29 | auto iter = m_cn2pool.find(cn); |
| 30 | if (iter == m_cn2pool.end()) { |
| 31 | iter = m_cn2pool |
| 32 | .emplace( |
| 33 | std::piecewise_construct, std::forward_as_tuple(cn), |
| 34 | std::forward_as_tuple(cn, m_flags)) |
| 35 | .first; |
| 36 | } |
| 37 | pool = &iter->second; |
| 38 | } |
| 39 | return pool->alloc(); |
| 40 | } |
| 41 | std::shared_ptr<CompNode::Event> EventPool::alloc_shared(CompNode cn) { |
| 42 | auto* raw_event = alloc(cn); |
| 43 | return {raw_event, [this](CompNode::Event* event) { this->free(event); }}; |