14 #ifdef MRPT_OS_WINDOWS 17 #include <sys/types.h> 33 #ifdef MRPT_OS_WINDOWS 36 if (!CreatePipe(&hRead, &hWrite,
nullptr, 0))
53 : timeout_read_start_us(0), timeout_read_between_us(0), m_pipe_file(0)
63 #ifdef MRPT_OS_WINDOWS 85 std::istringstream ss;
88 #ifdef MRPT_OS_WINDOWS 110 std::stringstream ss;
111 #ifdef MRPT_OS_WINDOWS 131 #if defined(MRPT_OS_WINDOWS) 134 if (!ReadFile((HANDLE)
m_pipe_file, Buffer, Count, &nActuallyRead,
nullptr))
137 return static_cast<size_t>(nActuallyRead);
148 size_t alreadyRead = 0;
149 bool timeoutExpired =
false;
151 struct timeval timeoutSelect;
152 struct timeval* ptrTimeout;
160 while (alreadyRead < Count && !timeoutExpired)
163 unsigned int curTimeout_us = alreadyRead == 0
167 if (curTimeout_us == 0)
168 ptrTimeout =
nullptr;
171 timeoutSelect.tv_sec = curTimeout_us / 1000000;
172 timeoutSelect.tv_usec = (curTimeout_us % 1000000);
173 ptrTimeout = &timeoutSelect;
185 timeoutExpired =
true;
190 const size_t remainToRead = Count - alreadyRead;
193 const size_t readNow = ::read(
197 if (readNow != static_cast<size_t>(-1))
200 alreadyRead += readNow;
208 if (readNow == 0 && remainToRead != 0)
213 timeoutExpired =
true;
230 #ifdef MRPT_OS_WINDOWS 232 DWORD nActuallyWritten;
234 (HANDLE)
m_pipe_file, Buffer, Count, &nActuallyWritten,
nullptr))
237 return static_cast<size_t>(nActuallyWritten);
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
TSeekOrigin
Used in CStream::Seek.
#define THROW_EXCEPTION(msg)
std::string serialize()
Converts the end-point into a string suitable for reconstruction at a child process.
The write end-point in a pipe created with mrpt::synch::CPipe.
virtual uint64_t getPosition() override
Without effect in this class.
virtual size_t Write(const void *Buffer, size_t Count) override
Introduces a pure virtual method responsible for writing to the stream.
unsigned int timeout_read_start_us
(Default=0) Timeout for read operations: microseconds (us) to wait for the first byte.
virtual ~CPipeBaseEndPoint()
static void initializePipe(CPipeReadEndPoint &outReadPipe, CPipeWriteEndPoint &outWritePipe)
Creates a new pipe and returns the read & write end-points as newly allocated objects.
The read end-point in a pipe created with mrpt::synch::CPipe.
virtual uint64_t Seek(uint64_t Offset, CStream::TSeekOrigin Origin=sFromBeginning) override
Without effect in this class.
virtual size_t Read(void *Buffer, size_t Count) override
Introduces a pure virtual method responsible for reading from the stream.
virtual uint64_t getTotalBytesCount() override
Without effect in this class.
GLsizei const GLchar ** string
unsigned __int64 uint64_t
Common interface of read & write pipe end-points.
void close()
Closes the pipe (normally not needed to be called by users, automatically done at destructor) ...
unsigned int timeout_read_between_us
(Default=0) Timeout between burst reads operations: microseconds (us) to wait between two partial rea...
#define ASSERTMSG_(f, __ERROR_MSG)