15 #ifdef MRPT_OS_WINDOWS 18 # include <sys/types.h> 32 # ifdef MRPT_OS_WINDOWS 35 if (!CreatePipe(&hRead, &hWrite, NULL, 0))
53 CPipeBaseEndPoint::CPipeBaseEndPoint() :
54 timeout_read_start_us(0),
55 timeout_read_between_us(0),
70 # ifdef MRPT_OS_WINDOWS 91 std::istringstream ss;
94 #ifdef MRPT_OS_WINDOWS 112 std::stringstream ss;
113 #ifdef MRPT_OS_WINDOWS 134 #if defined(MRPT_OS_WINDOWS) 137 if (!ReadFile((HANDLE)
m_pipe_file, Buffer, Count,&nActuallyRead, NULL ))
139 else return static_cast<size_t>(nActuallyRead);
149 size_t alreadyRead = 0;
150 bool timeoutExpired =
false;
152 struct timeval timeoutSelect;
153 struct timeval *ptrTimeout;
161 while ( alreadyRead<Count && !timeoutExpired )
166 if (curTimeout_us==0)
170 timeoutSelect.tv_sec = curTimeout_us / 1000000;
171 timeoutSelect.tv_usec = (curTimeout_us % 1000000);
172 ptrTimeout = &timeoutSelect;
184 timeoutExpired =
true;
189 const size_t remainToRead = Count - alreadyRead;
192 const size_t readNow = ::read(
m_pipe_file,((
char*)Buffer) + alreadyRead, (
int)remainToRead);
194 if (readNow != static_cast<size_t>(-1))
197 alreadyRead += readNow;
205 if (readNow==0 && remainToRead!=0)
209 timeoutExpired =
true;
225 #ifdef MRPT_OS_WINDOWS 227 DWORD nActuallyWritten;
228 if (!WriteFile((HANDLE)
m_pipe_file, Buffer, Count,&nActuallyWritten, NULL ))
230 else return static_cast<size_t>(nActuallyWritten);
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
virtual uint64_t Seek(int64_t Offset, CStream::TSeekOrigin Origin=sFromBeginning) MRPT_OVERRIDE
Without effect in this class.
TSeekOrigin
Used in CStream::Seek.
virtual uint64_t getTotalBytesCount() MRPT_OVERRIDE
Without effect in this class.
#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.
unsigned int timeout_read_start_us
(Default=0) Timeout for read operations: microseconds (us) to wait for the first byte. 0 means infinite timeout.
virtual ~CPipeBaseEndPoint()
The read end-point in a pipe created with mrpt::synch::CPipe.
This namespace provides multitask, synchronization utilities.
GLsizei const GLchar ** string
virtual size_t Read(void *Buffer, size_t Count) MRPT_OVERRIDE
Introduces a pure virtual method responsible for reading from the stream.
unsigned __int64 uint64_t
Common interface of read & write pipe end-points.
virtual uint64_t getPosition() MRPT_OVERRIDE
Without effect in this class.
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...
virtual size_t Write(const void *Buffer, size_t Count) MRPT_OVERRIDE
Introduces a pure virtual method responsible for writing to the stream.
#define ASSERTMSG_(f, __ERROR_MSG)