MayaFlux 0.1.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ add_batch()

template<typename OpClass >
size_t MayaFlux::Yantra::OperationPool::add_batch ( const std::unordered_map< std::string, std::shared_ptr< OpClass > > &  operations)
inline

Add multiple operations at once.

Template Parameters
OpClassOperation class type
Parameters
operationsMap of names to operations
Returns
Number of operations successfully added

Definition at line 453 of file OperationPool.hpp.

454 {
455 std::unique_lock lock(m_mutex);
456
457 size_t added = 0;
458 for (const auto& [name, op] : operations) {
459 if (op && !m_operations.contains(name)) {
460 m_operations[name] = std::static_pointer_cast<void>(op);
461
462 PooledOperationInfo info;
463 info.name = name;
464 info.type = std::type_index(typeid(OpClass));
465 info.created_at = std::chrono::steady_clock::now();
466 info.last_accessed = info.created_at;
467 info.access_count = 0;
468
469 m_info[name] = std::move(info);
470 added++;
471
472 if (m_on_add_callback) {
473 m_on_add_callback(name, info.type);
474 }
475 }
476 }
477
478 return added;
479 }
std::function< void(const std::string &, std::type_index)> m_on_add_callback
std::unordered_map< std::string, PooledOperationInfo > m_info
std::unordered_map< std::string, OperationPtr > m_operations

References MayaFlux::Yantra::PooledOperationInfo::access_count, MayaFlux::Yantra::PooledOperationInfo::created_at, MayaFlux::Yantra::PooledOperationInfo::last_accessed, m_info, m_mutex, m_on_add_callback, m_operations, MayaFlux::Yantra::PooledOperationInfo::name, and MayaFlux::Yantra::PooledOperationInfo::type.