static int bpsIOHandler(int fd, int io_events, void *data) { qEventDispatcherDebug << Q_FUNC_INFO; // decode callback payload bpsIOHandlerData *ioData = static_cast<bpsIOHandlerData*>(data); // check if first file is ready bool firstReady = (ioData->count == 0); // update ready state of file if (io_events & BPS_IO_INPUT) { qEventDispatcherDebug << fd << "ready for Read"; FD_SET(fd, ioData->readfds); ioData->count++; } if (io_events & BPS_IO_OUTPUT) { qEventDispatcherDebug << fd << "ready for Write"; FD_SET(fd, ioData->writefds); ioData->count++; } if (io_events & BPS_IO_EXCEPT) { qEventDispatcherDebug << fd << "ready for Exception"; FD_SET(fd, ioData->exceptfds); ioData->count++; } // force bps_get_event() to return immediately by posting an event to ourselves; // but this only needs to happen once if multiple files become ready at the same time if (firstReady) { qEventDispatcherDebug << "Sending bpsIOReadyDomain event"; // create unblock event bps_event_t *event; int result = bps_event_create(&event, bpsUnblockDomain, 0, NULL, NULL); if (Q_UNLIKELY(result != BPS_SUCCESS)) { qWarning("QEventDispatcherBlackberry: bps_event_create failed"); return BPS_FAILURE; } // post unblock event to our thread; in this callback the bps channel is // guaranteed to be the same that was active when bps_add_fd was called result = bps_push_event(event); if (Q_UNLIKELY(result != BPS_SUCCESS)) { qWarning("QEventDispatcherBlackberry: bps_push_event failed"); bps_event_destroy(event); return BPS_FAILURE; } } return BPS_SUCCESS; }
static int bpsIOHandler(int fd, int io_events, void *data) { // decode callback payload bpsIOHandlerData *ioData = static_cast<bpsIOHandlerData*>(data); // check if first file is ready bool firstReady = (ioData->count == 0); // update ready state of file if (io_events & BPS_IO_INPUT) { FD_SET(fd, ioData->readfds); ioData->count++; } if (io_events & BPS_IO_OUTPUT) { FD_SET(fd, ioData->writefds); ioData->count++; } if (io_events & BPS_IO_EXCEPT) { FD_SET(fd, ioData->exceptfds); ioData->count++; } // force bps_get_event() to return immediately by posting an event to ourselves; // but this only needs to happen once if multiple files become ready at the same time if (firstReady) { // create IO ready event bps_event_t *event; int result = bps_event_create(&event, bpsIOReadyDomain, 0, NULL, NULL); if (result != BPS_SUCCESS) { qWarning("QEventDispatcherBlackberryPrivate::QEventDispatcherBlackberry: bps_event_create() failed"); return BPS_FAILURE; } // post IO ready event to our thread result = bps_push_event(event); if (result != BPS_SUCCESS) { qWarning("QEventDispatcherBlackberryPrivate::QEventDispatcherBlackberry: bps_push_event() failed"); bps_event_destroy(event); return BPS_FAILURE; } } return BPS_SUCCESS; }