int wxSelectDispatcher::ProcessSets(const wxSelectSets& sets)
{
    int numEvents = 0;
    for ( int fd = 0; fd <= m_maxFD; fd++ )
    {
        if ( !sets.HasFD(fd) )
            continue;

        wxFDIOHandler * const handler = FindHandler(fd);
        if ( !handler )
        {
            wxFAIL_MSG( wxT("NULL handler in wxSelectDispatcher?") );
            continue;
        }

        if ( sets.Handle(fd, *handler) )
            numEvents++;
    }

    return numEvents;
}
Exemplo n.º 2
0
int wxSelectDispatcher::DoSelect(wxSelectSets& sets, int timeout) const
{
    struct timeval tv,
                  *ptv;
    if ( timeout != TIMEOUT_INFINITE )
    {
        ptv = &tv;
        tv.tv_sec = 0;
        tv.tv_usec = timeout*1000;
    }
    else // no timeout
    {
        ptv = NULL;
    }

    int ret = sets.Select(m_maxFD + 1, ptv);

    // TODO: we need to restart select() in this case but for now just return
    //       as if timeout expired
    if ( ret == -1 && errno == EINTR )
        ret = 0;

    return ret;
}