20 #ifndef HEDGEHOG_CORE_QUEUE_SLOT_H 21 #define HEDGEHOG_CORE_QUEUE_SLOT_H 23 #include <condition_variable> 28 #include "../../base/receiver/core_slot.h" 38 std::shared_ptr<std::set<CoreNotifier *>>
notifiers_ =
nullptr;
48 CoreSlot(name, type, numberThreads) {
49 HLOG_SELF(0,
"Creating CoreQueueSlot with type: " << (
int) type <<
" and name: " << name)
50 notifiers_ = std::make_shared<std::set<CoreNotifier *>>();
51 slotMutex_ = std::make_shared<std::mutex>();
52 notifyConditionVariable_ = std::make_shared<std::condition_variable>();
77 std::lock_guard<std::mutex> lc(*(this->slotMutex_));
85 std::lock_guard<std::mutex> lc(*(this->slotMutex_));
94 "Test has notifier connected " <<
"(" << std::boolalpha << (
bool) (this->
numberInputNodes() != 0) <<
")")
100 HLOG_SELF(2,
"Wake up and notify one")
106 HLOG_SELF(2,
"Lock unique mutex " << this->slotMutex_.get())
112 HLOG_SELF(2,
"Unlock unique mutex " << this->slotMutex_.get())
113 slotMutex_->unlock();
119 HLOG_SELF(0,
"Copy Cluster CoreQueueSlot information from " << rhs->
name() <<
"(" << rhs->
id() <<
")")
132 #endif //HEDGEHOG_CORE_QUEUE_SLOT_H NodeType type() const
Node type accessor.
void addNotifier(CoreNotifier *notifier) final
Add a notifier to set of CoreNotifier.
CoreQueueSlot(std::string_view const &name, NodeType const type, size_t const numberThreads)
CoreQueueSlot constructor.
bool hasNotifierConnected() final
Test if CoreNotifier are linked to this CoreQueueSlot.
Core Notifier interface, emit notification to CoreSlot.
std::shared_ptr< std::mutex > const & slotMutex() const
Mutex accessor.
Slot of CoreQueueMultiReceiver, receiving from CoreQueueNotifier.
std::shared_ptr< std::set< CoreNotifier * > > const & notifiers() const
Protected accessor to the set of notifiers connected to the CoreQueueSlot.
std::shared_ptr< std::condition_variable > notifyConditionVariable_
Condition Variable linked to the CoreQueueSlot::slotMutex_.
void copyInnerStructure(CoreQueueSlot *rhs)
Copy the inner structure of the receiver (mutex, condition variable and set of notifiers) ...
std::shared_ptr< std::mutex > slotMutex_
Mutex locking the CoreQueueMultiReceiver.
Slot interface, receive notification from CoreNotifier.
NodeType
Hedgehog node's type.
void removeNotifier(CoreNotifier *notifier) final
Remove a notifier from set of CoreNotifier.
size_t numberInputNodes() const final
Number of CoreNotifier linked accessor.
void unlockUniqueMutex()
Unlock the mutex.
std::shared_ptr< std::condition_variable > const & notifyConditionVariable() const
Condition variable accessor.
~CoreQueueSlot() override
CoreQueueSlot destructor.
std::string_view const & name() const
Node name accessor.
void wakeUp() final
Wake up and notify a node connected to the condition variable CoreQueueSlot::notifyConditionVariable_...
void lockUniqueMutex()
Lock the mutex.
std::shared_ptr< std::set< CoreNotifier * > > notifiers_
Set of notifiers linked to this CoreQueueSlot.
size_t numberThreads() const
Number of threads associated accessor.
virtual std::string id() const
Unique Id accessor.