VideoTools
|
A one-way, unreliable-datagram communication channel from a parent process to a child process, using shared memory. More...
#include <gfatpipe.h>
Classes | |
struct | ControlMemory |
Shared memory structure for G::FatPipe. More... | |
struct | DataMemory |
Shared memory structure for G::FatPipe. More... | |
struct | Lock |
RAII class to lock the G::FatPipe control segment. More... | |
Public Types | |
typedef FatPipeReceiver | Receiver |
Public Member Functions | |
FatPipe () | |
Constructor. | |
~FatPipe () | |
Destructor. | |
void | doParent (bool auto_cleanup=true) |
To be called from the parent process after fork(). | |
void | doChild () |
To be called from the child process after fork(). | |
void | send (const char *data, size_t size, const char *type=nullptr) |
Sends a chunk of data to the child process. More... | |
void | send (const std::vector< char > &data, const char *type=nullptr) |
Sends a chunk of data to the child process. More... | |
void | send (const std::vector< std::pair< const char *, size_t > > &data, const char *type=nullptr) |
Sends a segmented data to the child process. More... | |
void | send (const std::vector< std::vector< char > > &data, const char *type=nullptr) |
Sends chunked data to the child process. More... | |
bool | ping () |
Returns true if the receiver seems to be there. | |
const char * | shmemfd () const |
Returns the shared memory file descriptor as a string pointer (suitable for exec()). More... | |
const char * | pipefd () const |
Returns the pipe file descriptor as a string pointer (suitable for exec()). | |
A one-way, unreliable-datagram communication channel from a parent process to a child process, using shared memory.
Update events are sent from the parent process via an inherited non-blocking file descriptor. The shared memory file descriptor and the event file descriptor are typically passed to the child process via its command-line.
The implementation actuall uses two shared memory segments; a fixed size control segment containing a mutex, and a data segment that is resized as necessary. They are unlinked from the file system as soon as they are created, so they are almost never visible.
A socketpair() pipe is used for the data-available event signalling.
The child process typically obtains the control segment's file descriptor from its command-line, whereas the data segment's file descriptor is passed over the event pipe.
Definition at line 78 of file gfatpipe.h.
void G::FatPipe::send | ( | const char * | data, |
size_t | size, | ||
const char * | type = nullptr |
||
) |
Sends a chunk of data to the child process.
This will block in sendmsg() on first use or if the shared memory is grown in order to transfer the data fd.
Definition at line 155 of file gfatpipe.cpp.
void G::FatPipe::send | ( | const std::vector< char > & | data, |
const char * | type = nullptr |
||
) |
Sends a chunk of data to the child process.
This will block in sendmsg() on first use or if the shared memory is grown in order to transfer the data fd.
Definition at line 165 of file gfatpipe.cpp.
void G::FatPipe::send | ( | const std::vector< std::pair< const char *, size_t > > & | data, |
const char * | type = nullptr |
||
) |
Sends a segmented data to the child process.
This will block in sendmsg() on first use or if the shared memory is grown in order to transfer the data fd.
Definition at line 175 of file gfatpipe.cpp.
void G::FatPipe::send | ( | const std::vector< std::vector< char > > & | data, |
const char * | type = nullptr |
||
) |
Sends chunked data to the child process.
This will block in sendmsg() on first use or if the shared memory is grown in order to transfer the data fd.
Definition at line 190 of file gfatpipe.cpp.
const char * G::FatPipe::shmemfd | ( | ) | const |
Returns the shared memory file descriptor as a string pointer (suitable for exec()).
Definition at line 135 of file gfatpipe.cpp.