rogue
Loading...
Searching...
No Matches
Fifo.h
Go to the documentation of this file.
1
17#ifndef __ROGUE_INTERFACES_STREAM_FIFO_H__
18#define __ROGUE_INTERFACES_STREAM_FIFO_H__
19#include "rogue/Directives.h"
20
21#include <stdint.h>
22
23#include <atomic>
24#include <memory>
25#include <thread>
26
27#include "rogue/Logging.h"
30
31namespace rogue {
32namespace interfaces {
33namespace stream {
34
55 std::shared_ptr<rogue::Logging> log_;
56
57 // Configurations
58 uint32_t maxDepth_;
59 uint32_t trimSize_;
60 bool noCopy_;
61
62 // Drop frame counter
63 std::atomic<std::size_t> dropFrameCnt_{0};
64
65 // Queue
67
69 protected:
70 std::atomic<bool> threadEn_{false};
71 std::thread* thread_ = nullptr;
73
74 private:
75 // Thread background
76 void runThread();
77
78 public:
97 static std::shared_ptr<rogue::interfaces::stream::Fifo> create(uint32_t maxDepth, uint32_t trimSize, bool noCopy);
98
100 static void setup_python();
101
114 Fifo(uint32_t maxDepth, uint32_t trimSize, bool noCopy);
115
117 ~Fifo();
118
120 std::size_t size();
121
123 std::size_t dropCnt() const;
124
126 void clearCnt();
127
133 void acceptFrame(std::shared_ptr<rogue::interfaces::stream::Frame> frame);
134};
135
137typedef std::shared_ptr<rogue::interfaces::stream::Fifo> FifoPtr;
138} // namespace stream
139} // namespace interfaces
140} // namespace rogue
141#endif
Thread-safe bounded queue with optional busy threshold.
Definition Queue.h:39
Stream frame FIFO.
Definition Fifo.h:54
void acceptFrame(std::shared_ptr< rogue::interfaces::stream::Frame > frame)
Receives a frame from upstream and enqueues or drops it.
Definition Fifo.cpp:108
static void setup_python()
Registers this type with Python bindings.
Definition Fifo.cpp:49
std::size_t size()
Returns current FIFO queue depth.
Definition Fifo.cpp:93
std::size_t dropCnt() const
Returns the total dropped-frame counter.
Definition Fifo.cpp:98
void clearCnt()
Clears FIFO counters (including dropped-frame count).
Definition Fifo.cpp:103
~Fifo()
Destroys the FIFO and stops internal worker thread.
Definition Fifo.cpp:80
Stream master endpoint.
Definition Master.h:65
static std::shared_ptr< rogue::interfaces::stream::Master > create()
Creates a stream master.
Definition Master.cpp:40
Stream slave endpoint and default frame pool.
Definition Slave.h:72
std::shared_ptr< rogue::interfaces::stream::Fifo > FifoPtr
Shared pointer alias for Fifo.
Definition Fifo.h:137