// SPDX-License-Identifier: MIT /** Copyright (c) 2015 - 2022 Beckhoff Automation GmbH & Co. KG */ #pragma once #include "Notification.h" #include "AmsHeader.h" #include "Semaphore.h" #include #include #include #include namespace Beckhoff { namespace Ads { using DeleteNotificationCallback = std::function; struct NotificationDispatcher { NotificationDispatcher(DeleteNotificationCallback callback); ~NotificationDispatcher(); void Emplace(uint32_t hNotify, std::shared_ptr notification); long Erase(uint32_t hNotify, uint32_t tmms); void Notify(); void Run(); const DeleteNotificationCallback deleteNotification; RingBuffer ring; private: std::map > notifications; std::recursive_mutex mutex; Semaphore sem; std::atomic stopExecution; std::thread thread; std::shared_ptr Find(uint32_t hNotify); }; using SharedDispatcher = std::shared_ptr; } }