moved poll into select

This commit is contained in:
Aleksandar Fabijanic
2010-03-29 01:37:52 +00:00
parent c1817be572
commit ee893eb764
3 changed files with 10 additions and 26 deletions

View File

@@ -91,11 +91,9 @@ Socket::~Socket()
}
int Socket::poll(SocketList& readList, SocketList& writeList, SocketList& exceptList, const Poco::Timespan& timeout)
int Socket::select(SocketList& readList, SocketList& writeList, SocketList& exceptList, const Poco::Timespan& timeout)
{
#if !defined(POCO_HAVE_FD_POLL)
throw NotImplementedException("poll() is only available on POSIX platforms");
#else
#if defined(POCO_HAVE_FD_POLL)
nfds_t nfd = readList.size() + writeList.size() + exceptList.size();
if (0 == nfd) return 0;
@@ -173,15 +171,12 @@ int Socket::poll(SocketList& readList, SocketList& writeList, SocketList& except
}
std::swap(readList, readyReadList);
std::swap(writeList, readyWriteList);
std::swap(exceptList, readyExceptList);
std::swap(exceptList, readyExceptList);
// return rc;
return readList.size() + writeList.size() + exceptList.size();
#endif
}
int Socket::select(SocketList& readList, SocketList& writeList, SocketList& exceptList, const Poco::Timespan& timeout)
{
#else
fd_set fdRead;
fd_set fdWrite;
fd_set fdExcept;
@@ -250,8 +245,10 @@ int Socket::select(SocketList& readList, SocketList& writeList, SocketList& exce
if (FD_ISSET(it->sockfd(), &fdExcept))
readyExceptList.push_back(*it);
}
std::swap(exceptList, readyExceptList);
return rc;
std::swap(exceptList, readyExceptList);
return rc;
#endif
}

View File

@@ -121,11 +121,7 @@ void SocketReactor::run()
{
onIdle();
}
#if defined(POCO_HAVE_FD_POLL)
else if (Socket::poll(readable, writable, except, _timeout))
#else
else if (Socket::select(readable, writable, except, _timeout))
#endif
{
for (Socket::SocketList::iterator it = readable.begin(); it != readable.end(); ++it)
dispatch(*it, _pReadableNotification);