VirtualBox

Changeset 31453 in vbox for trunk/src/VBox/Runtime


Ignore:
Timestamp:
Aug 8, 2010 1:30:35 PM (14 years ago)
Author:
vboxsync
Message:

Runtime/poll: Add a method to change the events to poll for without removing and adding the source again

Location:
trunk/src/VBox/Runtime/r3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r3/posix/poll-posix.cpp

    r28800 r31453  
    480480}
    481481
     482
     483RTDECL(int) RTPollSetEventsChange(RTPOLLSET hPollSet, uint32_t id, uint32_t fEvents)
     484{
     485    /*
     486     * Validate the input.
     487     */
     488    RTPOLLSETINTERNAL *pThis = hPollSet;
     489    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
     490    AssertReturn(pThis->u32Magic == RTPOLLSET_MAGIC, VERR_INVALID_HANDLE);
     491    AssertReturn(id != UINT32_MAX, VERR_INVALID_PARAMETER);
     492    AssertReturn(!(fEvents & ~RTPOLL_EVT_VALID_MASK), VERR_INVALID_PARAMETER);
     493    AssertReturn(fEvents, VERR_INVALID_PARAMETER);
     494
     495    /*
     496     * Set the busy flag and do the job.
     497     */
     498    AssertReturn(ASMAtomicCmpXchgBool(&pThis->fBusy, true,  false), VERR_CONCURRENT_ACCESS);
     499
     500    int         rc = VERR_POLL_HANDLE_ID_NOT_FOUND;
     501    uint32_t    i  = pThis->cHandles;
     502    while (i-- > 0)
     503        if (pThis->paHandles[i].id == id)
     504        {
     505            pThis->paPollFds[i].events  = 0;
     506            if (fEvents & RTPOLL_EVT_READ)
     507                pThis->paPollFds[i].events |= POLLIN;
     508            if (fEvents & RTPOLL_EVT_WRITE)
     509                pThis->paPollFds[i].events |= POLLOUT;
     510            if (fEvents & RTPOLL_EVT_ERROR)
     511                pThis->paPollFds[i].events |= POLLERR;
     512            rc = VINF_SUCCESS;
     513            break;
     514        }
     515
     516    ASMAtomicWriteBool(&pThis->fBusy, false);
     517    return rc;
     518}
     519
  • trunk/src/VBox/Runtime/r3/win/poll-win.cpp

    r28800 r31453  
    552552}
    553553
     554RTDECL(int) RTPollSetEventsChange(RTPOLLSET hPollSet, uint32_t id, uint32_t fEvents)
     555{
     556    /*
     557     * Validate the input.
     558     */
     559    RTPOLLSETINTERNAL *pThis = hPollSet;
     560    AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
     561    AssertReturn(pThis->u32Magic == RTPOLLSET_MAGIC, VERR_INVALID_HANDLE);
     562    AssertReturn(id != UINT32_MAX, VERR_INVALID_PARAMETER);
     563    AssertReturn(!(fEvents & ~RTPOLL_EVT_VALID_MASK), VERR_INVALID_PARAMETER);
     564    AssertReturn(fEvents, VERR_INVALID_PARAMETER);
     565
     566    /*
     567     * Set the busy flag and do the job.
     568     */
     569    AssertReturn(ASMAtomicCmpXchgBool(&pThis->fBusy, true,  false), VERR_CONCURRENT_ACCESS);
     570
     571    int         rc = VERR_POLL_HANDLE_ID_NOT_FOUND;
     572    uint32_t    i  = pThis->cHandles;
     573    while (i-- > 0)
     574        if (pThis->paHandles[i].id == id)
     575        {
     576            pThis->aHandles[i].fEvents = fEvents;
     577            rc = VINF_SUCCESS;
     578            break;
     579        }
     580
     581    ASMAtomicWriteBool(&pThis->fBusy, false);
     582    return rc;
     583}
     584
     585
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette