Hedgehog  0.0.0
A library to generate hybrid pipeline workflow systems
core_queue_multi_receivers.h
1 // NIST-developed software is provided by NIST as a public service. You may use, copy and distribute copies of the
2 // software in any medium, provided that you keep intact this entire notice. You may improve, modify and create
3 // derivative works of the software or any portion of the software, and you may copy and distribute such modifications
4 // or works. Modified works should carry a notice stating that you changed the software and should note the date and
5 // nature of any such change. Please explicitly acknowledge the National Institute of Standards and Technology as the
6 // source of the software. NIST-developed software is expressly provided "AS IS." NIST MAKES NO WARRANTY OF ANY KIND,
7 // EXPRESS, IMPLIED, IN FACT OR ARISING BY OPERATION OF LAW, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTY OF
8 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT AND DATA ACCURACY. NIST NEITHER REPRESENTS NOR
9 // WARRANTS THAT THE OPERATION OF THE SOFTWARE WILL BE UNINTERRUPTED OR ERROR-FREE, OR THAT ANY DEFECTS WILL BE
10 // CORRECTED. NIST DOES NOT WARRANT OR MAKE ANY REPRESENTATIONS REGARDING THE USE OF THE SOFTWARE OR THE RESULTS
11 // THEREOF, INCLUDING BUT NOT LIMITED TO THE CORRECTNESS, ACCURACY, RELIABILITY, OR USEFULNESS OF THE SOFTWARE. You
12 // are solely responsible for determining the appropriateness of using and distributing the software and you assume
13 // all risks associated with its use, including but not limited to the risks and costs of program errors, compliance
14 // with applicable laws, damage to or loss of data, programs or equipment, and the unavailability or interruption of
15 // operation. This software is not intended to be used in any situation where a failure could cause risk of injury or
16 // damage to property. The software developed by NIST employees is not subject to copyright protection within the
17 // United States.
18 
19 
20 #ifndef HEDGEHOG_CORE_QUEUE_MULTI_RECEIVERS_H
21 #define HEDGEHOG_CORE_QUEUE_MULTI_RECEIVERS_H
22 
23 #include "../../base/receiver/core_multi_receivers.h"
24 #include "core_queue_slot.h"
25 #include "core_queue_receiver.h"
26 
28 namespace hh::core {
29 
32 template<class ...NodeInputs>
34  : public CoreMultiReceivers<NodeInputs...>, public CoreQueueSlot, public CoreQueueReceiver<NodeInputs> ... {
35  public:
36 
37  // Suppress wrong static analysis, Constructor called used
42  explicit CoreQueueMultiReceivers(std::string_view const &name, NodeType const type, size_t const numberThreads) :
43  CoreNode(name, type, numberThreads),
44  CoreSlot(name, type, numberThreads),
45  CoreReceiver<NodeInputs>(name, type, numberThreads)...,
46  CoreMultiReceivers<NodeInputs...>(name, type, numberThreads),
47  CoreQueueSlot(name, type, numberThreads),
48  CoreQueueReceiver<NodeInputs>(name, type, numberThreads)
49  ... {
50  HLOG_SELF(0, "Creating CoreQueueMultiReceivers with type: " << (int) type << " and name: " << name)
51  }
52 
54  ~CoreQueueMultiReceivers() override {HLOG_SELF(0, "Destructing CoreQueueMultiReceivers")}
55 
58  bool receiversEmpty() final {
59  HLOG_SELF(2, "Test all destinations empty")
60  return (static_cast<CoreReceiver<NodeInputs> *>(this)->receiverEmpty() && ...);
61  }
62 
65  size_t totalQueueSize() final { return (static_cast<CoreReceiver<NodeInputs> *>(this)->queueSize() + ...); }
66 
69  std::set<CoreSlot *> getSlots() final { return {this}; }
70 
73  CoreQueueSlot *queueSlot() final { return this; };
74 
75  // Suppress wrong static analysis
79  HLOG_SELF(0, "Copy Cluster information from " << rhs->name() << "(" << rhs->id() << ")")
82  }
83 };
84 
85 }
86 #endif //HEDGEHOG_CORE_QUEUE_MULTI_RECEIVERS_H
NodeType type() const
Node type accessor.
Definition: core_node.h:132
Receiver Interface, receive one data type from CoreSender.
Definition: core_receiver.h:44
size_t queueSize() override
Return the current waiting data queue size.
Slot of CoreQueueMultiReceiver, receiving from CoreQueueNotifier.
Multi receiver interface, gather multiple CoreReceiver.
void copyInnerStructure(CoreQueueSlot *rhs)
Copy the inner structure of the receiver (mutex, condition variable and set of notifiers) ...
CoreQueueSlot * queueSlot() final
Return the node&#39;s slot.
Slot interface, receive notification from CoreNotifier.
Definition: core_slot.h:34
std::set< CoreSlot * > getSlots() final
Return a set of slots, {this}.
Receiver for nodes possessing a queue of data.
CoreQueueMultiReceivers(std::string_view const &name, NodeType const type, size_t const numberThreads)
CoreQueueMultiReceivers constructor.
NodeType
Hedgehog node&#39;s type.
Definition: core_node.h:40
bool receiverEmpty() final
Test emptiness on the queue.
Main Hedgehog core abstraction.
Definition: core_node.h:48
Multi receivers for nodes possessing a queue of data.
Hedgehog core namespace.
Definition: core_execute.h:25
std::string_view const & name() const
Node name accessor.
Definition: core_node.h:128
bool receiversEmpty() final
Test emptiness of all receivers.
size_t numberThreads() const
Number of threads associated accessor.
Definition: core_node.h:152
~CoreQueueMultiReceivers() override
CoreQueueMultiReceivers destructor.
virtual std::string id() const
Unique Id accessor.
Definition: core_node.h:114
void copyInnerStructure(CoreQueueMultiReceivers< NodeInputs... > *rhs)
Copy the inner structure of all receivers and the slot from rhs to this.
size_t totalQueueSize() final
Sums the queue sizes for all receivers.