54 size_t size =
_pipes.size();
57 for (
size_t index = 0; index < size; index++)
59 close(
_pipes[index].readpipe);
60 close(
_pipes[index].writepipe);
73 flags = ::fcntl(fd, F_GETFL, 0);
79 result = fcntl(fd , F_SETFL , flags);
121 for (
size_t index = 0; index < sizePipeArray; index++)
165 result = ::read(fd, &ch, 1);
179 _pipes[pipesindex].fDataPending =
false;
195 size_t size =
_pipes.size();
197 for (
size_t index = 0; index < size; index++)
199 if ((
_pipes[index].readpipe == fd) || (
_pipes[index].writepipe == fd))
210 size_t size =
_pipes.size();
213 for (
size_t index = 0; index < size; index++)
215 if (
_pipes[index].fDataPending)
228 size_t size =
_pipes.size();
235 close(
_pipes[pipeindex].readpipe);
236 _pipes[pipeindex].readpipe = -1;
238 close(
_pipes[pipeindex].writepipe);
239 _pipes[pipeindex].writepipe = -1;
270 for (
int index = 0; index < 100; index++)
273 size_t item = rand() % size;
304 const size_t c_maxSockets = 10;
315 for (
size_t index = 0; index < 1000; index++)
317 int randresult = ::rand() % 4;
324 if (
_pipes.size() >= c_maxSockets)
337 size_t size =
_pipes.size();
345 itemindex = rand() % size;
381 const size_t c_maxSockets = 10;
const uint32_t IPOLLING_TYPE_EPOLL
HRESULT RemovePipe(int pipeindex)
virtual HRESULT WaitForNextEvent(PollEvent *pPollEvent, int timeoutMilliseconds)=0
HRESULT CreatePollingInstance(uint32_t type, size_t maxSockets, IPolling **ppPolling)
const uint32_t IPOLLING_TYPE_POLL
HRESULT CreateAndAddPipe()
CRefCountedPtr< IPolling > _spPolling
virtual HRESULT Add(int fd, uint32_t eventflags)=0
std::vector< PipePair > _pipes
const uint32_t IPOLLING_READ
HRESULT TestInit(size_t sizePolling, size_t sizePipeArray)
virtual HRESULT Remove(int fd)=0
HRESULT ConsumeEvent(int *pFD, int *pCount)
int FindPipePairIndex(int fd)
HRESULT WritePipe(PipePair *pPipePair)
HRESULT SetNonBlocking(int fd)
#define ChkIfA(expr, hrerror)