int select_watchevent(struct eventreq *req, int which) { return select_modwatch(req, which); }
void EventContext::RequestEvent(int theMask) { #if DEBUG fModwatched = true; #endif // // The first time this function gets called, we're supposed to // call watchevent. Each subsequent time, call modwatch. That's // the way the MacOS X event queue works. if (fWatchEventCalled) { fEventReq.er_eventbits = theMask; #if MACOSXEVENTQUEUE if (modwatch(&fEventReq, theMask) != 0) #else if (select_modwatch(&fEventReq, theMask) != 0) #endif AssertV(false, OSThread::GetErrno()); } else { //allocate a Unique ID for this socket, and add it to the ref table #ifdef __Win32__ // // Kind of a hack. On Win32, the way that we pass around the unique ID is // by making it the message ID of our Win32 message (see win32ev.cpp). // Messages must be >= WM_USER. Hence this code to restrict the numberspace // of our UniqueIDs. if (!compare_and_store(8192, WM_USER, &sUniqueID)) // Fix 2466667: message IDs above a fUniqueID = (PointerSizedInt)atomic_add(&sUniqueID, 1); // level are ignored, so wrap at 8192 else fUniqueID = (PointerSizedInt)WM_USER; #else if (!compare_and_store(10000000, 1, &sUniqueID)) fUniqueID = (PointerSizedInt)atomic_add(&sUniqueID, 1); else fUniqueID = 1; #endif fRef.Set(fUniqueIDStr, this); Assert(fEventThread->fRefTable.Register(&fRef) == OS_NoErr); //fill out the eventreq data structure ::memset( &fEventReq, '\0', sizeof(fEventReq)); fEventReq.er_type = EV_FD; fEventReq.er_handle = fFileDesc; fEventReq.er_eventbits = theMask; fEventReq.er_data = (void*)fUniqueID; fWatchEventCalled = true; #if MACOSXEVENTQUEUE if (watchevent(&fEventReq, theMask) != 0) #else if (select_watchevent(&fEventReq, theMask) != 0) #endif //this should never fail, but if it does, cleanup. AssertV(false, OSThread::GetErrno()); } }