-#ifdef HAVE_POLL
- #define wxPoll poll
- #define wxPollFd pollfd
-#else // !HAVE_POLL
-
-typedef GPollFD wxPollFd;
-
-int wxPoll(wxPollFd *ufds, unsigned int nfds, int timeout)
-{
- // convert timeout from ms to struct timeval (s/us)
- timeval tv_timeout;
- tv_timeout.tv_sec = timeout/1000;
- tv_timeout.tv_usec = (timeout%1000)*1000;
-
- // remember the highest fd used here
- int fdMax = -1;
-
- // and fill the sets for select()
- fd_set readfds;
- fd_set writefds;
- fd_set exceptfds;
- FD_ZERO(&readfds);
- FD_ZERO(&writefds);
- FD_ZERO(&exceptfds);
-
- unsigned int i;
- for ( i = 0; i < nfds; i++ )
- {
- wxASSERT_MSG( ufds[i].fd < FD_SETSIZE, _T("fd out of range") );
-
- if ( ufds[i].events & G_IO_IN )
- FD_SET(ufds[i].fd, &readfds);
-
- if ( ufds[i].events & G_IO_PRI )
- FD_SET(ufds[i].fd, &exceptfds);
-
- if ( ufds[i].events & G_IO_OUT )
- FD_SET(ufds[i].fd, &writefds);
-
- if ( ufds[i].fd > fdMax )
- fdMax = ufds[i].fd;
- }
-
- fdMax++;
- int res = select(fdMax, &readfds, &writefds, &exceptfds, &tv_timeout);
-
- // translate the results back
- for ( i = 0; i < nfds; i++ )
+ bool keepSource = false;
+ // if a new idle source has not been added, either as a result of idle
+ // processing above or by another thread calling WakeUpIdle()
+ if (m_idleSourceId == 0)