static void rb_set_subtract_callback(const void *value, void *context) { CFMutableSetRef *sets = context; if (CFSetContainsValue(sets[0], RB2OC(value))) CFSetRemoveValue(sets[1], RB2OC(value)); }
static VALUE rb_set_delete(VALUE set, SEL sel, VALUE obj) { rb_set_modify_check(set); CFSetRemoveValue((CFMutableSetRef)set, (const void *)RB2OC(obj)); return set; }
static void _DiskDisappeared(DADiskRef disk, void *context) { if (weLikeTheDisk(disk)) { CFSetRemoveValue(gExternalMediaSet, disk); adjustExternalDiskAssertion(); } }
static void formUnschedule(CFReadStreamRef stream, CFRunLoopRef runLoop, CFStringRef runLoopMode, void* context) { FormStreamFields* form = static_cast<FormStreamFields*>(context); if (form->currentStream) CFReadStreamUnscheduleFromRunLoop(form->currentStream, runLoop, runLoopMode); SchedulePair pair = { runLoop, runLoopMode }; CFSetRemoveValue(form->scheduledRunLoopPairs, &pair); }
static VALUE rb_set_delete2(VALUE set, SEL sel, VALUE obj) { rb_set_modify_check(set); if (CFSetContainsValue((CFMutableSetRef)set, (const void *)RB2OC(obj))) { CFSetRemoveValue((CFMutableSetRef)set, (const void *)RB2OC(obj)); return set; } else return Qnil; }
bool SOSAccountVerifyAndAcceptHSAApplicants(SOSAccountRef account, SOSCircleRef newCircle, CFErrorRef *error) { SOSFullPeerInfoRef fpi = account->my_identity; __block bool circleChanged = false; CFMutableSetRef approvals = SOSAccountCopyPreApprovedHSA2Info(account); if(approvals && CFSetGetCount(approvals) > 0) { SOSCircleForEachApplicant(newCircle, ^(SOSPeerInfoRef peer) { CFStringRef peerID = SOSPeerInfoGetPeerID(peer); if(CFSetContainsValue(approvals, peerID)) { SOSPeerInfoRef copypi = SOSPeerInfoCreateCopy(NULL, peer, NULL); circleChanged = SOSCircleAcceptRequest(newCircle, SOSAccountGetPrivateCredential(account, NULL), fpi, copypi, error); CFSetRemoveValue(approvals, peerID); } });
void _cfmp_record_nsmachport_deallocation(_CFMPLifetimeClient const client, mach_port_t const port, Boolean const doSend, Boolean const doReceive) { if (port == MACH_PORT_NULL) { return; } if (doSend == false && doReceive == false) { return; } CFMutableSetRef records = _cfmp_records(); Boolean cleanupNow = false; _cfmp_deallocation_record R = {0}; os_unfair_lock_lock(&_cfmp_records_lock); _cfmp_deallocation_record *const pr = _cfmp_find_record_for_port(records, client, port); if (pr == NULL) { R.port = port; R.nsportDoSend = doSend; R.nsportDoReceive = doReceive; cleanupNow = true; } else { // we're expecting invalidation. record that we want to doSend/Receive for nsport later // but first make sure we were expecting an NSMachPort at all if (!pr->nsportIsInterested) { _cfmp_log_failure("setting nsport state - when its not interested", pr, client, port); } else if (pr->invalidated) { // it's already been invalidated, so can tidy up now R = *(_cfmp_deallocation_record *)pr; CFSetRemoveValue(records, pr); cleanupNow = true; } else { // we're expecting invalidation, record that we want clean up doSend/Receive for later pr->deallocated = true; pr->nsportDoSend = doSend; pr->nsportDoReceive = doReceive; } } os_unfair_lock_unlock(&_cfmp_records_lock); if (cleanupNow) { _cfmp_cleanup(R); } }
void _cfmp_source_invalidated(_CFMPLifetimeClient const client, mach_port_t port) { Boolean cleanupNow = false; _cfmp_deallocation_record R = {0}; CFMutableSetRef const records = _cfmp_records(); os_unfair_lock_lock(&_cfmp_records_lock); _cfmp_deallocation_record *pr = _cfmp_find_record_for_port(records, client, port); if (pr == NULL) { _cfmp_log_failure("not expecting invalidation", pr, client, port); } else { if (pr->deallocated) { cleanupNow = true; R = *(_cfmp_deallocation_record *)pr; CFSetRemoveValue(records, pr); } else { pr->invalidated = true; } } os_unfair_lock_unlock(&_cfmp_records_lock); if (cleanupNow) { _cfmp_cleanup(R); } }
/// Records that a given mach_port has been deallocated. void _cfmp_record_deallocation(_CFMPLifetimeClient const client, mach_port_t const port, Boolean const doSend, Boolean const doReceive) { if (port == MACH_PORT_NULL) { return; } if (doSend == false && doReceive == false) { return; } // now that we know we're not a no-op, look for an existing deallocation record CFMutableSetRef records = _cfmp_records(); Boolean cleanupNow = false; _cfmp_deallocation_record R = {0}; os_unfair_lock_lock(&_cfmp_records_lock); _cfmp_deallocation_record *const pr = _cfmp_find_record_for_port(records, client, port); if (pr) { if (pr->invalidated) { // it's already been invalidated, so can tidy up now R = *(_cfmp_deallocation_record *)pr; CFSetRemoveValue(records, pr); cleanupNow = true; } else { // we're expecting invalidation, record that we want clean up doSend/Receive for later pr->deallocated = true; pr->doSend = doSend; pr->doReceive = doReceive; } } else { R.port = port; R.doSend = doSend; R.doReceive = doReceive; cleanupNow = true; } os_unfair_lock_unlock(&_cfmp_records_lock); if (cleanupNow) { _cfmp_cleanup(R); } }
static void GPDuplexClient_RemoveObserverWithNumberAndObserverSet(GPDuplexClientRef client, void* observer, GPDuplexClientCallback callback, CFNumberRef typeNumber, CFMutableSetRef observerSet) { CFDataRef observerData = GPDuplexClientCreateObserver(observer, callback); CFSetRemoveValue(observerSet, observerData); if (CFSetGetCount(observerSet) == 0) CFDictionaryRemoveValue(client->observers, typeNumber); }