1 #ifndef fdwriterthread_HEADER_GUARD
2 #define fdwriterthread_HEADER_GUARD
38 #include <sys/select.h>
56 inline std::ostream& operator<< (std::ostream& os,
const FDWriteContext& ctx) {
58 os <<
"<FDWriteContext : slot = " << ctx.
slot <<
" / fd = " << ctx.
fd <<
" >";
75 std::deque<Frame*> internal_fifo;
95 enum class FDWriteSignal {
108 FDWriteSignal signal;
143 struct timeval timeout;
158 int safeGetSlot (
const SlotNumber slot,
FDWrite*& fd_write);
Passes frames to a multiprocessing fifo.
Definition: framefilter.h:554
FrameFifo using file descriptors.
Definition: framefifo.h:132
File Descriptor Writer Thread.
Definition: fdwritethread.h:124
std::list< FDWrite * > fd_writes
For iterating over the FDWrite entries.
Definition: fdwritethread.h:140
void preRun()
Called before entering the main execution loop, but after creating the thread.
Definition: fdwritethread.cpp:222
void requestStopCall()
API method: stops the thread.
Definition: fdwritethread.cpp:377
FDWriteThread(const char *name, FrameFifoContext fifo_ctx=FrameFifoContext())
Default constructor.
Definition: fdwritethread.cpp:51
std::vector< FDWrite * > slots_
For fast, pointer-arithmetic-based indexing of the slots.
Definition: fdwritethread.h:139
void preJoin()
Called before the thread is joined.
Definition: fdwritethread.cpp:228
void handleSignal(const FDWriteSignalContext &signal_ctx)
Handle an individual signal.
Definition: fdwritethread.cpp:235
BlockingFifoFrameFilter infilter_block
Incoming frames can also be written here. If stack runs out of frames, writing will block.
Definition: fdwritethread.h:138
FifoFrameFilter & getFrameFilter()
API method: get filter for sending frames // <pyapi>
Definition: fdwritethread.cpp:398
FDFrameFifo infifo
Incoming frames (also signal frames) are read from here.
Definition: fdwritethread.h:136
fd_set read_fds
File descriptor sets used by select.
Definition: fdwritethread.h:141
void run()
Main execution loop is defined here.
Definition: fdwritethread.cpp:130
void registerStreamCall(const FDWriteContext &ctx)
API method: registers a stream // <pyapi>
Definition: fdwritethread.cpp:337
void deregisterStreamCall(const FDWriteContext &ctx)
API method: de-registers a stream // <pyapi>
Definition: fdwritethread.cpp:357
int nfds
Max file descriptor number.
Definition: fdwritethread.h:142
FifoFrameFilter infilter
Write incoming frames here // TODO: add a chain of correcting FrameFilter(s)
Definition: fdwritethread.h:137
void postJoin()
Called after the thread has been joined.
Definition: fdwritethread.cpp:231
void postRun()
Called after the main execution loop exits, but before joining the thread.
Definition: fdwritethread.cpp:225
Definition: fdwritethread.h:66
FDWrite(FrameFifo &fifo, const FDWriteContext &ctx)
Default constructor.
Definition: fdwritethread.cpp:39
const FDWriteContext & ctx
Identifies the connection type, stream address, etc.
Definition: fdwritethread.h:73
virtual ~FDWrite()
Default virtual destructor.
Definition: fdwritethread.cpp:43
FrameFifo & fifo
Outgoing Frames are finally recycled here.
Definition: fdwritethread.h:74
Passes frames to a FrameFifo.
Definition: framefilter.h:530
A thread-safe combination of a fifo (first-in-first-out) queue and an associated stack.
Definition: framefifo.h:83
A class for multithreading with a signaling system.
Definition: thread.h:87
std::string name
Name of the thread.
Definition: thread.h:116
Thread safe system of fifo and a stack.
Definition of FrameFilter and derived classes for various purposes.
Describes an outgoing file descriptor connection.
Definition: fdwritethread.h:49
SlotNumber slot
A unique stream slot that identifies this stream // <pyapi>
Definition: fdwritethread.h:53
int fd
file descriptor // <pyapi>
Definition: fdwritethread.h:52
Encapsulate data sent to FDWriteThread with a SignalFrame.
Definition: fdwritethread.h:107
Information sent with a signal to FDWriteThread.
Definition: fdwritethread.h:86
FDWriteContext fd_write_ctx
< Identifies the stream
Definition: fdwritethread.h:88
Describes the stack structure and fifo behaviour for a FrameFifo.
Definition: framefifo.h:56
Base class for multithreading.
@ none
undefined (initial value)
Definition: usbthread.h:143