static void hid_device_removal_callback(void *context, IOReturn result, void *sender) { /* Stop the Run Loop for this device. */ hid_device *d = context; d->disconnected = 1; CFRunLoopStop(d->run_loop); }
CF_EXPORT void rwsched_instance_CFRunLoopStop(rwsched_instance_ptr_t instance) { // Validate input parameters RW_CF_TYPE_VALIDATE(instance, rwsched_instance_ptr_t); // Call the native CFRunLoopStop function CFRunLoopStop(CFRunLoopGetCurrent()); }
static PyObject *pypowerobserver_stop(PyPowerObserver *self, PyObject *args, PyObject *kwargs) { CFRunLoopStop(self->runLoop); Py_INCREF(Py_None); return Py_None; }
void HIDDevice::stop(void) { if ( cfRunLoop ) { CFRunLoopStop ( cfRunLoop ) ; Threads::Mutex::Lock stateLock ( runLoopMutex ) ; (*hidQueueInterface) -> stop ( hidQueueInterface ) ; stopDeviceThread ( ) ; } }
kern_return_t sectask_server_request(mach_port_t receiver, audit_token_t auditToken) { memcpy(&g_self_audittoken, &auditToken, sizeof(g_self_audittoken)); CFRunLoopStop(CFRunLoopGetCurrent()); return 0; }
static void timeout_cb(CFRunLoopTimerRef timer, void *context) { (void) timer; bool *timed_out = (bool *) context; *timed_out = true; CFRunLoopStop(CFRunLoopGetCurrent()); }
static void btpad_close_all_connections(void) { int i; for (i = 0; i < MAX_USERS; i ++) btpad_close_connection(&g_connections[i]); /* TODO/FIXME - create platform-agnostic solution for this * and figure out why/if this is needed. */ CFRunLoopStop(CFRunLoopGetCurrent()); }
static void _stream_handler(ConstFSEventStreamRef stream, void *info, size_t numEvents, void *eventPaths, const FSEventStreamEventFlags eventFlags[], const FSEventStreamEventId eventIds[]) { const char **paths = eventPaths; streamobject *object = info; PyObject *result = NULL, *str = NULL, *num = NULL; assert(numEvents <= PY_SSIZE_T_MAX); PyGILState_STATE gil_state = PyGILState_Ensure(); PyThreadState *thread_state = PyThreadState_Swap(object->state); /* Convert event data to Python objects */ PyObject *event_paths = PyList_New(numEvents); if (!event_paths) { goto final; } PyObject *event_flags = PyList_New(numEvents); if (!event_flags) { goto final; } for (size_t i = 0; i < numEvents; i++) { str = PyBytes_FromString(paths[i]); #if PY_MAJOR_VERSION >= 3 num = PyLong_FromLong(eventFlags[i]); #else num = PyInt_FromLong(eventFlags[i]); #endif if ((!num) || (!str)) { goto final; } PyList_SET_ITEM(event_paths, i, str); PyList_SET_ITEM(event_flags, i, num); } str = NULL; num = NULL; if ( (result = PyObject_CallFunctionObjArgs( object->callback, event_paths, event_flags, NULL)) == NULL) { /* May can return NULL if an exception is raised */ if (!PyErr_Occurred()) PyErr_SetString(PyExc_ValueError, callback_error_msg); /* Stop listening */ CFRunLoopStop(object->loop); } final:
static void output_callback(hid_t *context, IOReturn ret, void *sender, IOHIDReportType type, uint32_t id, uint8_t *data, CFIndex len) { printf("output_callback, r=%d\n", ret); if (ret == kIOReturnSuccess) { *(int *)context = len; } else { // timeout if not success? *(int *)context = 0; } CFRunLoopStop(CFRunLoopGetCurrent()); }
void QFSEventsFileSystemWatcherEngine::stop() { #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 QMutexLocker locker(&mutex); stopFSStream(fsStream); if (threadsRunLoop) { CFRunLoopStop(threadsRunLoop); waitForStop.wait(&mutex); } #endif }
static void btpad_close_all_connections(void) { unsigned i; for (i = 0; i < MAX_USERS; i ++) btpad_close_connection(&g_connections[i]); #ifdef __APPLE__ CFRunLoopStop(CFRunLoopGetCurrent()); #endif }
static PyObject* pyfsevents_stop(PyObject* self, PyObject* thread) { PyObject* value = PyDict_GetItem(loops, thread); CFRunLoopRef loop = PyCObject_AsVoidPtr(value); /* stop runloop */ if (loop) { CFRunLoopStop(loop); } Py_INCREF(Py_None); return Py_None; }
static void fse_pipe_callback(CFFileDescriptorRef fdref, CFOptionFlags callBackTypes, void *info) { w_root_t *root = info; unused_parameter(fdref); unused_parameter(callBackTypes); unused_parameter(root); w_log(W_LOG_DBG, "pipe signalled\n"); CFRunLoopStop(CFRunLoopGetCurrent()); }
static Boolean GotPacket(ConnectionRef conn, const PacketHeader *packet, void *refCon) // DoListen registers this routine with the connection abstraction layer // so that it is called when a packet arrives. For a description of the // parameters, see the comments next to ConnectionCallbackProcPtr. { #pragma unused(conn) Boolean result; CFRunLoopRef runLoop; // When we register this callback, we pass a reference to the runloop // as the refCon. Extract that reference here. runLoop = (CFRunLoopRef) refCon; assert(runLoop != NULL); assert( CFGetTypeID(runLoop) == CFRunLoopGetTypeID() ); result = true; if (packet == NULL) { // Server connection has gone away. No need to return false because // the connection is torn anyway. CFRunLoopStop(runLoop); } else { // We got a packet from the server. Tell the user about it. switch (packet->fType) { case kPacketTypeShout: if (packet->fSize != sizeof(PacketShout)) { fprintf(stderr, "GotPacket: Server sent us a Shout with the wrong size (%" PRIu32 ").\n", packet->fSize); result = false; } if (result && (packet->fID != kPacketIDNone) ) { fprintf(stderr, "GotPacket: Server sent us a Shout with the wrong size (%" PRId32 ").\n", packet->fID); result = false; } if (result) { PacketShout * shoutPacket; shoutPacket = (PacketShout *) packet; fprintf(stderr, "%*s heard \"%.*s\"\n", kResultColumnWidth, "", (int) sizeof(shoutPacket->fMessage), shoutPacket->fMessage); } break; default: fprintf(stderr, "GotPacket: Server sent us a packet with an unexpected type (%.4s).\n", (char *) &packet->fType); result = false; break; } } return result; }
void usb_cleanup() { DBG("usb_cleanup\n"); close_usb_devices(); if (currentRunLoop) CFRunLoopStop(currentRunLoop); if (notificationIterators != NULL) { free(notificationIterators); notificationIterators = NULL; } }
void PsychHIDOSKbQueueRelease(int deviceIndex) { // Get true keyboardqueue index assigned to deviceIndex from original user provided deviceIndex: deviceIndex = PsychHIDOSGetKbQueueDevice(deviceIndex, NULL); // Keyboard queue for this deviceIndex already exists? if (NULL == psychHIDKbQueueFirstPress[deviceIndex]) { // No. Nothing to do then. return; } // Ok, we have a keyboard queue. Stop any operation on it first: PsychHIDOSKbQueueStop(deviceIndex); // The mutex will be automatically unlocked and destroyed by the CFRunLoop thread // so it isn't even declared in this routine if (psychHIDKbQueueCFRunLoopRef[deviceIndex]) { // Shutdown the processing thread for this queue: PsychLockMutex(&KbQueueMutex); // Stop the CFRunLoop, which will allow its associated thread to exit: CFRunLoopStop(psychHIDKbQueueCFRunLoopRef[deviceIndex]); // Done. PsychUnlockMutex(&KbQueueMutex); // Shutdown the thread, wait for its termination: PsychDeleteThread(&KbQueueThread[deviceIndex]); KbQueueThread[deviceIndex] = NULL; // Release the CFRunLoop for this queue: CFRelease(psychHIDKbQueueCFRunLoopRef[deviceIndex]); psychHIDKbQueueCFRunLoopRef[deviceIndex] = NULL; // Release queue object: CFRelease(queue[deviceIndex]); queue[deviceIndex] = NULL; } // Release its data structures: free(psychHIDKbQueueFirstPress[deviceIndex]); psychHIDKbQueueFirstPress[deviceIndex] = NULL; free(psychHIDKbQueueFirstRelease[deviceIndex]); psychHIDKbQueueFirstRelease[deviceIndex] = NULL; free(psychHIDKbQueueLastPress[deviceIndex]); psychHIDKbQueueLastPress[deviceIndex] = NULL; free(psychHIDKbQueueLastRelease[deviceIndex]); psychHIDKbQueueLastRelease[deviceIndex] = NULL; free(psychHIDKbQueueScanKeys[deviceIndex]); psychHIDKbQueueScanKeys[deviceIndex] = NULL; // Release kbqueue event buffer: PsychHIDDeleteEventBuffer(deviceIndex); // Done. return; }
static void console_user_changed_cb(SCDynamicStoreRef store, CFArrayRef changedKeys, void *context) { CFStringRef user; uid_t uid; gid_t gid; user = SCDynamicStoreCopyConsoleUser(store, &uid, &gid); if (user != NULL) { CFRelease(user); CFRunLoopStop(CFRunLoopGetCurrent()); } }
/** * @brief input Called to add input data to the buffer * @param[in] id Report id * @param[in] data The data buffer * @param[in] len The report length */ void pjrc_rawhid::input(uint8_t *data, CFIndex len) { if (!device_open) return; if (len > BUFFER_SIZE) len = BUFFER_SIZE; // Note: packet preprocessing done in OS independent code memcpy(buffer, &data[0], len); buffer_count = len; if (received_runloop) CFRunLoopStop(received_runloop); }
void SCNetworkEventPublisher::stop() { if (run_loop_ == nullptr) { // No need to stop if there is not run loop. return; } for (const auto& target : targets_) { SCNetworkReachabilityUnscheduleFromRunLoop( target, run_loop_, kCFRunLoopDefaultMode); } CFRunLoopStop(run_loop_); }
static void detach_callback(void *context, IOReturn r, void *hid_mgr, IOHIDDeviceRef dev) { hid_t *p; printf("detach callback\n"); for (p = first_hid; p; p = p->next) { if (p->ref == dev) { p->open = 0; CFRunLoopStop(CFRunLoopGetCurrent()); return; } } }
int key_stop(void) { if (eventTap == NULL) { warnx("tried to stop listening when not initialized"); return -1; } CFRunLoopStop(CFRunLoopGetCurrent()); CGEventTapEnable(eventTap, false); return 0; }
void fsevents_monitor::on_stop() { lock_guard<mutex> run_loop_lock(run_mutex); if (!run_loop) throw libfsw_exception(_("run loop is null")); FSW_ELOG(_("Stopping event stream...\n")); FSEventStreamStop(stream); stream = nullptr; FSW_ELOG(_("Stopping run loop...\n")); CFRunLoopStop(run_loop); run_loop = nullptr; }
void SystemEventsManager::stopLoop(bool forceStop) { if (systemEventLoopRunning && (forceStop || allEventsDisabled())) { CFRunLoopRemoveSource(CFRunLoopGetCurrent(), IONotificationPortGetRunLoopSource(notifyPortRef), kCFRunLoopCommonModes); IODeregisterForSystemPower(¬ifierObject); IOServiceClose(rootPort); IONotificationPortDestroy(notifyPortRef); CFRunLoopStop(CFRunLoopGetCurrent()); systemEventLoopRunning = false; } }
void signal_handler(int sig) { switch(sig) { case SIGHUP: if(!quiet) fprintf(stderr, "received SIGHUP signal, not supported\n"); CFRunLoopStop(CFRunLoopGetCurrent()); break; case SIGTERM: if(!quiet) fprintf(stderr, "received SIGTERM signal, terminating\n"); run = false; CFRunLoopStop(CFRunLoopGetCurrent()); break; case SIGINT: if(!quiet) fprintf(stderr, "received SIGINT signal, terminating\n"); run = false; CFRunLoopStop(CFRunLoopGetCurrent()); break; case SIGQUIT: if(!quiet) fprintf(stderr, "received SIGQUIT signal, terminating\n"); run = false; CFRunLoopStop(CFRunLoopGetCurrent()); break; default: fprintf(stderr, "uhandled signal (%d) %s\n", sig, strsignal(sig)); break; } }
void Sys_Input_Shutdown(struct input_data *input) { input->thread_shutdown = true; CFRunLoopStop(input->threadrunloop); pthread_join(input->thread, 0); pthread_mutex_destroy(&input->mouse_mutex); pthread_mutex_destroy(&input->key_mutex); pthread_mutex_destroy(&input->thread_mutex); pthread_cond_destroy(&input->thread_has_spawned); free(input); }
bool Activity::HandleActivityMessage(android::PMessage message) { if (message->GetWhat()==WhatActivityMessage::PAUSE_ACTIVITY || message->GetWhat()==WhatActivityMessage::PAUSE_ACTIVITY_FINISHING) { LOG("Preparing to exit..."); HandleActivityMessages(false); android::PMessage messageCopy=android::Message::Obtain(message); message->GetTarget()->SendMessage(messageCopy); android::Looper::MyLooper()->Quit(); CFRunLoopStop(CFRunLoopGetMain()); return true; } return false; }
COSXScreen::~COSXScreen() { disable(); m_events->adoptBuffer(NULL); m_events->removeHandler(CEvent::kSystem, m_events->getSystemTarget()); if (m_pmWatchThread) { // make sure the thread has setup the runloop. { CLock lock(m_pmMutex); while (!(bool)*m_pmThreadReady) { m_pmThreadReady->wait(); } } // now exit the thread's runloop and wait for it to exit LOG((CLOG_DEBUG "stopping watchSystemPowerThread")); CFRunLoopStop(m_pmRunloop); m_pmWatchThread->wait(); delete m_pmWatchThread; m_pmWatchThread = NULL; } delete m_pmThreadReady; delete m_pmMutex; m_events->removeHandler(m_events->forCOSXScreen().confirmSleep(), getEventTarget()); RemoveEventHandler(m_switchEventHandlerRef); #if defined(MAC_OS_X_VERSION_10_5) CGDisplayRemoveReconfigurationCallback(displayReconfigurationCallback, this); #else DMRemoveExtendedNotifyProc(m_displayManagerNotificationUPP, NULL, &m_PSN, 0); if (m_hiddenWindow) { ReleaseWindow(m_hiddenWindow); m_hiddenWindow = NULL; } if (m_userInputWindow) { ReleaseWindow(m_userInputWindow); m_userInputWindow = NULL; } #endif delete m_keyState; delete m_screensaver; }
void DiskArbitrationEventPublisher::stop() { if (run_loop_ == nullptr) { return; } WriteLock lock(mutex_); if (session_ != nullptr) { DASessionUnscheduleFromRunLoop(session_, run_loop_, kCFRunLoopDefaultMode); CFRelease(session_); session_ = nullptr; } CFRunLoopStop(run_loop_); }
/* Callback function which will recieve the 'mounted' notification * from FUSE. It is full with debug code... but I'll let it stay * that way. */ static void NotificationCallback(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) { if(DEBUGMODE) { char buffer[512]; LOG_DEBUG("Received notification:\n"); if(CFStringGetCString(name, buffer, 512, kCFStringEncodingUTF8) == true) LOG_DEBUG(" Name: %s\n", buffer); else LOG_DEBUG(" <Cound not get name>\n"); LOG_DEBUG(" userInfo:\n"); if(userInfo != NULL) CFDictionaryApplyFunction(userInfo, PrintDictEntry, NULL); else LOG_DEBUG(" <null>\n"); } if(userInfo != NULL) { // It's only null when testing const void *value = NULL; LOG_DEBUG("CFDictionaryGetValueIfPresent(%p, \"%s\", %p)\n", userInfo, FUSE_MOUNT_PATH_KEY, &value); if(CFDictionaryGetValueIfPresent(userInfo, CFSTR(FUSE_MOUNT_PATH_KEY), &value) == true) { LOG_DEBUG("CFStringGetTypeID(%p) == %lu ?\n", value, CFStringGetTypeID()); if(CFGetTypeID((CFStringRef)value) == CFStringGetTypeID()) { LOG_DEBUG(" yes.\n"); LOG_DEBUG("mountPath=%p\n", mountPath); if(mountPath != NULL) CFRelease(mountPath); // No memory leaks please. LOG_DEBUG("assigning mountpath the value %p\n", value); mountPath = (CFStringRef)value; CFRetain(mountPath); LOG_DEBUG("done with assigning.\n"); #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 CFRunLoopStop(CFRunLoopGetCurrent()); #endif } else LOG_DEBUG(" no."); } } }
static void interrupt_report_callback_func(void *target, IOReturn result, void *refcon, void *sender, UInt32 size) #endif { hidreport_t rep = (hidreport_t) target; if (verbose && (rep->size_received != 0)) printf("Warning: previous report has not been read.\n"); rep->size_received = size; CFRunLoopStop(CFRunLoopGetCurrent()); }