Pothos  0.4.3-gabce2ce6
The Pothos dataflow programming software suite
InputPort.hpp
Go to the documentation of this file.
1 
11 #pragma once
12 #include <Pothos/Config.hpp>
13 #include <Pothos/Object/Object.hpp>
19 #include <Pothos/Util/SpinLock.hpp>
20 #include <string>
21 
22 namespace Pothos {
23 
24 class WorkerActor;
25 class OutputPort;
26 
31 {
32 public:
33 
35  ~InputPort(void);
36 
42  int index(void) const;
43 
45  const std::string &name(void) const;
46 
48  const std::string &alias(void) const;
49 
51  void setAlias(const std::string &alias);
52 
54  const DType &dtype(void) const;
55 
57  const std::string &domain(void) const;
58 
63  const BufferChunk &buffer(void) const;
64 
69  size_t elements(void) const;
70 
76  unsigned long long totalElements(void) const;
77 
83  unsigned long long totalBuffers(void) const;
84 
90  unsigned long long totalLabels(void) const;
91 
97  unsigned long long totalMessages(void) const;
98 
100  bool hasMessage(void);
101 
107  const LabelIteratorRange &labels(void) const;
108 
117  void removeLabel(const Label &label);
118 
125  void consume(const size_t numElements);
126 
132  Object popMessage(void);
133 
139  Object peekMessage(void);
140 
153  void setReserve(const size_t numElements);
154 
158  bool isSlot(void) const;
159 
167  void pushBuffer(const BufferChunk &buffer);
168 
175  void pushLabel(const Label &label);
176 
181  void pushMessage(const Object &message);
182 
187  void clear(void);
188 
189 private:
190  WorkerActor *_actor;
191 
192  //port configuration
193  bool _isSlot;
194  int _index;
195  std::string _name;
196  std::string _alias;
197  DType _dtype;
198  std::string _domain;
199 
200  //state set in pre-work
201  BufferChunk _buffer;
202  size_t _elements;
203  LabelIteratorRange _labelIter;
204 
205  //port stats
206  unsigned long long _totalElements;
207  unsigned long long _totalBuffers;
208  unsigned long long _totalLabels;
209  unsigned long long _totalMessages;
210 
211  //state changes from work
212  size_t _pendingElements;
213  size_t _reserveElements;
214 
215  //counts work actions which we will use to establish activity
216  size_t _workEvents;
217 
218  Util::SpinLock _asyncMessagesLock;
220 
221  Util::SpinLock _slotCallsLock;
223 
224  std::vector<Label> _inlineMessages; //user api structure
225  Util::RingDeque<Label> _inputInlineMessages; //shared structure
226 
227  Util::SpinLock _bufferAccumulatorLock;
228  BufferAccumulator _bufferAccumulator;
229 
230  std::vector<OutputPort *> _subscribers;
231 
233  void asyncMessagesPush(const Object &message, const BufferChunk &token = BufferChunk::null());
234  bool asyncMessagesEmpty(void);
235  Object asyncMessagesPop(void);
236  Object asyncMessagesPeek(void);
237  void asyncMessagesClear(void);
238 
240  void slotCallsPush(const Object &args, const BufferChunk &token);
241  bool slotCallsEmpty(void);
242  Object slotCallsPop(void);
243  void slotCallsClear(void);
244 
246  void inlineMessagesPush(const Label &label);
247  void inlineMessagesClear(void);
248 
250  void bufferAccumulatorFront(BufferChunk &);
251  void bufferAccumulatorPush(const BufferChunk &buffer);
252  void bufferAccumulatorPushNoLock(const BufferChunk &buffer);
253  void bufferAccumulatorPop(const size_t numBytes);
254  void bufferAccumulatorRequire(const size_t numBytes);
255  void bufferAccumulatorClear(void);
256 
258  void bufferLabelPush(
259  const std::vector<Label> &postedLabels,
260  const Util::RingDeque<BufferChunk> &postedBuffers);
261 
262  InputPort(void);
263  InputPort(const InputPort &){} // non construction-copyable
264  InputPort &operator=(const InputPort &){return *this;} // non copyable
265  friend class WorkerActor;
266  friend class OutputPort;
267 };
268 
269 } //namespace Pothos
Definition: Label.hpp:23
Definition: BufferAccumulator.hpp:31
Definition: Label.hpp:86
#define POTHOS_API
Definition: Config.hpp:41
Definition: OutputPort.hpp:31
Definition: SpinLock.hpp:26
Definition: CallInterface.hpp:15
Definition: Object.hpp:55
Definition: InputPort.hpp:30
Definition: RingDeque.hpp:29
Definition: BufferChunk.hpp:30
Definition: DType.hpp:38
static const BufferChunk & null(void)
Get a const reference to a null/empty BufferChunk.