| 355 | |
| 356 | template <typename T> |
| 357 | T *PluginManager<T>::l_createObject(const std::string& objectType) |
| 358 | { |
| 359 | // Static plugins already here. |
| 360 | auto find([this, &objectType]()->bool |
| 361 | { |
| 362 | std::lock_guard<std::mutex> lock(m_pluginMutex); |
| 363 | return m_plugins.count(objectType); |
| 364 | }); |
| 365 | |
| 366 | if (find() || (l_loadDynamic(objectType) && find())) |
| 367 | { |
| 368 | // Kernels contain a PipelineManager, which may load other plugins, |
| 369 | // so the lock must be released prior to invoking the ctor to |
| 370 | // avoid deadlock. |
| 371 | std::function<T *()> f; |
| 372 | { |
| 373 | // Lock must be released before the creation function is invoked. |
| 374 | std::lock_guard<std::mutex> lock(m_pluginMutex); |
| 375 | f = m_plugins[objectType].create; |
| 376 | } |
| 377 | return f(); |
| 378 | } |
| 379 | return nullptr; |
| 380 | } |
| 381 | |
| 382 | |
| 383 | template <typename T> |