AdsLib
Loading...
Searching...
No Matches
NotificationDispatcher.h
1// SPDX-License-Identifier: MIT
6#pragma once
7
8#include "AdsNotification.h"
9#include "AmsHeader.h"
10#include "Semaphore.h"
11
12#include <atomic>
13#include <functional>
14#include <map>
15#include <thread>
16
17using DeleteNotificationCallback = std::function<long (uint32_t hNotify, uint32_t tmms)>;
18
20 NotificationDispatcher(DeleteNotificationCallback callback);
22 void Emplace(uint32_t hNotify, std::shared_ptr<Notification> notification);
23 long Erase(uint32_t hNotify, uint32_t tmms);
24 void Notify();
25 void Run();
26
27 const DeleteNotificationCallback deleteNotification;
28 RingBuffer ring;
29private:
30 std::map<uint32_t, std::shared_ptr<Notification> > notifications;
31 std::recursive_mutex mutex;
32 Semaphore sem;
33 std::atomic<bool> stopExecution;
34 std::thread thread;
35
36 std::shared_ptr<Notification> Find(uint32_t hNotify);
37};
38using SharedDispatcher = std::shared_ptr<NotificationDispatcher>;
Definition: NotificationDispatcher.h:19
Definition: RingBuffer.h:12
Definition: Semaphore.h:12