Get operation from pool with type safety.
- Template Parameters
-
| OpClass | Expected operation class type |
- Parameters
-
| name | Name of the operation |
- Returns
- Shared pointer to operation, or nullptr if not found/type mismatch
Definition at line 138 of file OperationPool.hpp.
139 {
140 std::shared_lock lock(
m_mutex);
141
144 return nullptr;
145 }
146
148 if (info_it !=
m_info.end()) {
149 if (info_it->second.type != std::type_index(typeid(OpClass))) {
150 return nullptr;
151 }
152
153 {
154 lock.unlock();
155 std::unique_lock write_lock(
m_mutex);
156 info_it->second.last_accessed = std::chrono::steady_clock::now();
157 info_it->second.access_count++;
158 }
159 }
160
161 return std::static_pointer_cast<OpClass>(it->second);
162 }
std::shared_mutex m_mutex
std::unordered_map< std::string, PooledOperationInfo > m_info
std::unordered_map< std::string, OperationPtr > m_operations
References m_info, m_mutex, m_operations, and name.