当前位置: 首页>>代码示例>>C++>>正文


C++ CFRunLoopRunInMode函数代码示例

本文整理汇总了C++中CFRunLoopRunInMode函数的典型用法代码示例。如果您正苦于以下问题:C++ CFRunLoopRunInMode函数的具体用法?C++ CFRunLoopRunInMode怎么用?C++ CFRunLoopRunInMode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了CFRunLoopRunInMode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: TeensyControls_find_new_usb_devices

void TeensyControls_find_new_usb_devices(void)
{
	while (1) {
		int r = CFRunLoopRunInMode(dev_run_mode, 0, true);
		if (r != kCFRunLoopRunHandledSource) break;
	}
}
开发者ID:orthopteroid,项目名称:X-Plane_Plugin,代码行数:7,代码来源:usb.c

示例2: main

int
main(int argc, char **argv)
{
    kern_return_t	kr;
    mach_port_t		service_port = MACH_PORT_NULL;

    openlog("eapolcfg_auth", LOG_CONS | LOG_PID, LOG_DAEMON);
    if (geteuid() != 0) {
	syslog(LOG_ERR, "not running as root - exiting");
	exit(EX_CONFIG);
    }
    kr = bootstrap_check_in(bootstrap_port, EAPOLCFG_AUTH_SERVER,
			    &service_port);
    if (kr != BOOTSTRAP_SUCCESS) {
	syslog(LOG_ERR, "bootstrap_check_in() failed: %s",
	       bootstrap_strerror(kr));
	exit(EX_UNAVAILABLE);
    }
    start_service(service_port);
    while (1) {
	SInt32	rlStatus;

	rlStatus = CFRunLoopRunInMode(kCFRunLoopDefaultMode, 15.0, TRUE);
	if (rlStatus == kCFRunLoopRunTimedOut) {
	    if (S_handled_request == FALSE) {
		/* we didn't handle a request in the last time interval */
		break;
	    }
	    S_handled_request = FALSE;
	}
    }
    exit(EX_OK);
    return (0);
}
开发者ID:carriercomm,项目名称:osx-2,代码行数:34,代码来源:eapolcfg_auth.c

示例3: iokit_unmount

static int iokit_unmount (MMCDEV *mmc) {
    if (0 == mmc->is_mounted) {
        return 0; /* nothing to do */
    }

    BD_DEBUG(DBG_MMC, "Unmounting disk\n");

    mmc->session = DASessionCreate (kCFAllocatorDefault);
    if (NULL == mmc->session) {
        BD_DEBUG(DBG_MMC, "Could not create a disc arbitration session\n");
        return -1;
    }

    mmc->disk = DADiskCreateFromBSDName (kCFAllocatorDefault, mmc->session, mmc->bsd_name);
    if (NULL == mmc->disk) {
        BD_DEBUG(DBG_MMC, "Could not create a disc arbitration disc for the device\n");
        CFRelease (mmc->session);
        mmc->session = NULL;
        return -1;
    }

    DAApprovalSessionScheduleWithRunLoop (mmc->session, CFRunLoopGetCurrent (),
                                          kCFRunLoopDefaultMode);

    DADiskUnmount (mmc->disk, kDADiskUnmountOptionForce, iokit_unmount_complete, mmc);

    CFRunLoopRunInMode (kCFRunLoopDefaultMode, 10, true);

    return mmc->is_mounted ? -1 : 0;
}
开发者ID:ffmpeg-build-win,项目名称:libaacs,代码行数:30,代码来源:mmc_device_darwin.c

示例4: IOHIDManagerCreate

void CInputProviderMacOsHid::InputDeviceListenerThread()
{
	m_hidManager = IOHIDManagerCreate(kCFAllocatorDefault, 0);
	{
		CFDictionaryRef matchingDict[3];
		matchingDict[0] = CreateDeviceMatchingDictionary(kHIDPage_GenericDesktop, kHIDUsage_GD_Joystick);
		matchingDict[1] = CreateDeviceMatchingDictionary(kHIDPage_GenericDesktop, kHIDUsage_GD_GamePad);
		matchingDict[2] = CreateDeviceMatchingDictionary(kHIDPage_GenericDesktop, kHIDUsage_GD_MultiAxisController);

		CFArrayRef array = CFArrayCreate(kCFAllocatorDefault, (const void**)matchingDict, 3, &kCFTypeArrayCallBacks);
		CFRelease(matchingDict[0]);
		CFRelease(matchingDict[1]);
		CFRelease(matchingDict[2]);
		IOHIDManagerSetDeviceMatchingMultiple(m_hidManager, array);
	}

	IOHIDManagerRegisterDeviceMatchingCallback(m_hidManager, OnDeviceMatchedStub, this);

	IOHIDManagerOpen(m_hidManager, kIOHIDOptionsTypeNone);
	IOHIDManagerScheduleWithRunLoop(m_hidManager, CFRunLoopGetCurrent(), CFSTR("CustomLoop"));
	while(CFRunLoopRunInMode(CFSTR("CustomLoop"), 1, true) != kCFRunLoopRunStopped && m_running)
	{
	}

	IOHIDManagerClose(m_hidManager, 0);
}
开发者ID:jpd002,项目名称:Play-,代码行数:26,代码来源:InputProviderMacOsHid.cpp

示例5: LOGGER_WARNING

bool HTTPInputSource::Open(CFErrorRef *error)
{
	if(IsOpen()) {
		LOGGER_WARNING("org.sbooth.AudioEngine.InputSource.HTTP", "Open() called on an InputSource that is already open");
		return true;
	}

	// Set up the HTTP request
	mRequest = CFHTTPMessageCreateRequest(kCFAllocatorDefault, CFSTR("GET"), mURL, kCFHTTPVersion1_1);
	if(NULL == mRequest) {
		if(error)
			*error = CFErrorCreate(kCFAllocatorDefault, kCFErrorDomainPOSIX, ENOMEM, NULL);
		return false;
	}

	CFHTTPMessageSetHeaderFieldValue(mRequest, CFSTR("User-Agent"), CFSTR("SFBAudioEngine"));

	// Seek support
	if(0 < mDesiredOffset) {
		CFStringRef byteRange = CFStringCreateWithFormat(kCFAllocatorDefault, NULL, CFSTR("bytes=%ld-"), mDesiredOffset);
		CFHTTPMessageSetHeaderFieldValue(mRequest, CFSTR("Range"), byteRange);
		CFRelease(byteRange), byteRange = NULL;
	}

	mReadStream = CFReadStreamCreateForStreamedHTTPRequest(kCFAllocatorDefault, mRequest, NULL);
	if(NULL == mReadStream) {
		CFRelease(mRequest), mRequest = NULL;
		if(error)
			*error = CFErrorCreate(kCFAllocatorDefault, kCFErrorDomainPOSIX, ENOMEM, NULL);
		return false;
	}

	// Start the HTTP connection
	CFStreamClientContext myContext = { 0, this, NULL, NULL, NULL };

	CFOptionFlags clientFlags = kCFStreamEventOpenCompleted | kCFStreamEventHasBytesAvailable | kCFStreamEventErrorOccurred | kCFStreamEventEndEncountered;
    if(!CFReadStreamSetClient(mReadStream, clientFlags, myCFReadStreamClientCallBack, &myContext)) {
		CFRelease(mRequest), mRequest = NULL;
		CFRelease(mReadStream), mReadStream = NULL;
		if(error)
			*error = CFErrorCreate(kCFAllocatorDefault, kCFErrorDomainPOSIX, ENOMEM, NULL);
		return false;
	}

	CFReadStreamScheduleWithRunLoop(mReadStream, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);

	if(!CFReadStreamOpen(mReadStream)) {
		CFRelease(mRequest), mRequest = NULL;
		CFRelease(mReadStream), mReadStream = NULL;
		if(error)
			*error = CFErrorCreate(kCFAllocatorDefault, kCFErrorDomainPOSIX, ENOMEM, NULL);
		return false;
	}

	while(NULL == mResponseHeaders)
		CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, true);

	mIsOpen = true;
	return true;
}
开发者ID:hjzc,项目名称:SFBAudioEngine,代码行数:60,代码来源:HTTPInputSource.cpp

示例6: while

void CL_SoundOutput_MacOSX::wait()
{
    while (fragments_available == 0)
    {
        CFRunLoopRunInMode(kCFRunLoopDefaultMode, 1, true);
    }
}
开发者ID:animehunter,项目名称:clanlib-2.3,代码行数:7,代码来源:soundoutput_macosx.cpp

示例7: DASessionCreate

/**
 * Use the DiskArbitration Daemon to inform us of media changes
 */
void MonitorThreadDarwin::run(void)
{
    CFDictionaryRef match     = kDADiskDescriptionMatchVolumeMountable;
    DASessionRef    daSession = DASessionCreate(kCFAllocatorDefault);

    IOMasterPort(MACH_PORT_NULL, &sMasterPort);

    DARegisterDiskAppearedCallback(daSession, match,
                                   diskAppearedCallback, this);
    DARegisterDiskDisappearedCallback(daSession, match,
                                      diskDisappearedCallback, this);
    DARegisterDiskDescriptionChangedCallback(daSession, match,
                                             kDADiskDescriptionWatchVolumeName,
                                             diskChangedCallback, this);

    DASessionScheduleWithRunLoop(daSession,
                                 CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);


    // Nice and simple, as long as our monitor is valid and active, 
    // loop and let daSession check the devices.
    while (m_Monitor && m_Monitor->IsActive())        
    {
        // Run the run loop for interval (milliseconds) - this will
        // handle any disk arbitration appeared/dissappeared events
        CFRunLoopRunInMode(kCFRunLoopDefaultMode,
                           (float) m_Interval / 1000.0f, false );
    }

    DAUnregisterCallback(daSession, (void(*))diskChangedCallback,     this);
    DAUnregisterCallback(daSession, (void(*))diskDisappearedCallback, this);
    DAUnregisterCallback(daSession, (void(*))diskAppearedCallback,    this);
    CFRelease(daSession);
}
开发者ID:royboy626,项目名称:mythtv,代码行数:37,代码来源:mediamonitor-darwin.cpp

示例8: atoi

    void TCPStream_CFNetwork::open()
    {
        if (!serviceName.empty() && serviceName.find_first_not_of("0123456789") == String::npos) {
            remoteHostName = domainName;
            remotePortNumber = atoi(serviceName.c_str());

            if (connect()) {
                handleOpenedEvent();
            }
            handleOpeningFailedEvent();
        }

        DNS::SRVRecordResolver resolver(serviceName, "tcp", domainName);
        resolver.start();
        while (!resolver.isDone()) {
            CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, false);
        }

        //The SRV lookup has completed. Get the results and try to connect
        auto results = DNS::SRVRecordResolver::prioritizeResults(resolver.getResults());

        for (auto result : results) {
            remoteHostName = result.target;
            remotePortNumber = result.port;
            if (connect()) {
                return handleOpenedEvent();
            }
        }

        return handleOpeningFailedEvent();
    }
开发者ID:DampKeg,项目名称:DampKeg,代码行数:31,代码来源:TCPStream_CFNetwork.cpp

示例9: ConfigHIDManager

static SDL_bool
ConfigHIDManager(CFArrayRef matchingArray)
{
    CFRunLoopRef runloop = CFRunLoopGetCurrent();

    /* Run in a custom RunLoop mode just while initializing,
       so we can detect sticks without messing with everything else. */
    CFStringRef tempRunLoopMode = CFSTR("SDLJoystickInit");

    if (IOHIDManagerOpen(hidman, kIOHIDOptionsTypeNone) != kIOReturnSuccess) {
        return SDL_FALSE;
    }

    IOHIDManagerRegisterDeviceMatchingCallback(hidman, JoystickDeviceWasAddedCallback, NULL);
    IOHIDManagerScheduleWithRunLoop(hidman, runloop, tempRunLoopMode);
    IOHIDManagerSetDeviceMatchingMultiple(hidman, matchingArray);

    while (CFRunLoopRunInMode(tempRunLoopMode,0,TRUE)==kCFRunLoopRunHandledSource) {
        /* no-op. Callback fires once per existing device. */
    }

    /* Put this in the normal RunLoop mode now, for future hotplug events. */
    IOHIDManagerUnscheduleFromRunLoop(hidman, runloop, tempRunLoopMode);
    IOHIDManagerScheduleWithRunLoop(hidman, runloop, kCFRunLoopDefaultMode);

    return SDL_TRUE;  /* good to go. */
}
开发者ID:Helios-vmg,项目名称:CopperRat,代码行数:27,代码来源:SDL_sysjoystick.c

示例10: pollCfLoop

 void
 pollCfLoop()
 {
   // this should dispatch ready events and exit
   CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, true);
   scheduleCfLoop();
 }
开发者ID:AaronTien,项目名称:ndn-cxx,代码行数:7,代码来源:network-monitor.cpp

示例11: printf

// Async processing thread for keyboard events:
static void *KbQueueWorkerThreadMain(void *inarg) {
    int deviceIndex = (int) inarg;
    int rc;

    // Switch ourselves (NULL) to RT scheduling: We promise to use / require at most (0+1) == 1 msec every
    // 10 msecs and allow for wakeup delay/jitter of up to 2 msecs -- perfectly reasonable, given that we
    // only do minimal << 1 msec processing, only at the timescale of human reaction times, and driven by
    // input devices with at least 4+/-4 msecs jitter at 8 msec USB polling frequency.
    if ((rc = PsychSetThreadPriority(NULL, 2, 0)) > 0) {
        printf("PsychHID: KbQueueCreate: Failed to switch to realtime priority [%s].\n", strerror(rc));
    }

    // Keep a global reference to the runloop, as we need it in KbQueueRelease to get this thread to exit:
    psychHIDKbQueueCFRunLoopRef[deviceIndex] = (CFRunLoopRef) CFRunLoopGetCurrent();
    CFRetain(psychHIDKbQueueCFRunLoopRef[deviceIndex]);

    // Add HID queue to current runloop:
    IOHIDQueueScheduleWithRunLoop(queue[deviceIndex], psychHIDKbQueueCFRunLoopRef[deviceIndex], kCFRunLoopDefaultMode);

    // Start the run loop, code execution will block here until run loop is stopped again by PsychHIDKbQueueRelease
    // Meanwhile, the run loop of this thread will be responsible for executing code below in PsychHIDKbQueueCalbackFunction
    while (CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.1, false) == kCFRunLoopRunTimedOut) {};

    // Remove HID queue from current runloop:
    IOHIDQueueUnscheduleFromRunLoop(queue[deviceIndex], psychHIDKbQueueCFRunLoopRef[deviceIndex], kCFRunLoopDefaultMode);

    // Done. Die peacefully:
    return(NULL);
}
开发者ID:Orca25,项目名称:Psychtoolbox-3,代码行数:30,代码来源:PsychHIDStandardInterfaces.c

示例12: while

Burger::RunQueue::eReturnCode BURGER_API Burger::Mouse::Poll(void *pData)
{
	while (CFRunLoopRunInMode(g_BurgerMouse,0,TRUE)==kCFRunLoopRunHandledSource) {
	}
#if 0
	Word i;
	Mouse *pMouse = static_cast<Mouse *>(pData);
	DeviceStruct *pRat = pMouse->m_Mice;
	for (i = 0; i < pMouse->m_uMiceCount; i++) {
		if (pRat->m_bUnplugged) {
			IOHIDDeviceRef pDevice = pRat->m_pDevice;
			if (pDevice) {
				if (IOHIDDeviceOpen(pDevice,kIOHIDOptionsTypeNone) == kIOReturnSuccess) {
					pRat->m_bUnplugged = FALSE;	// Connected!
					IOHIDDeviceRegisterRemovalCallback(pDevice,DisconnectionCallback,pMouse);
					IOHIDDeviceRegisterInputValueCallback(pDevice,InputCallback,pMouse);
					CFRunLoopRef pRunLoop = CFRunLoopGetCurrent();
					IOHIDDeviceScheduleWithRunLoop(pDevice,pRunLoop,g_BurgerMouse);
				}
			}
		}
		++pRat;
	}
#endif
	return RunQueue::OKAY;
}
开发者ID:Olde-Skuul,项目名称:burgerlib,代码行数:26,代码来源:brmousemacosx.cpp

示例13: caml_release_runtime_system

CFRunLoopRunResult osx_cf_run_loop_run_in_mode
(CFStringRef mode, CFTimeInterval seconds, Boolean returnAfterSourceHandled) {
  CFRunLoopRunResult r;
  caml_release_runtime_system();
  r = CFRunLoopRunInMode(mode, seconds, returnAfterSourceHandled);
  caml_acquire_runtime_system();
  return r;
}
开发者ID:yallop,项目名称:ocaml-osx-cf,代码行数:8,代码来源:osx_cf_util.c

示例14: while

void HIDJoystickManager::update()
{
    SInt32 status = kCFRunLoopRunHandledSource;
    
    while (status == kCFRunLoopRunHandledSource) {
        status = CFRunLoopRunInMode(RunLoopMode, 0, true);
    }
}
开发者ID:AdamFlores,项目名称:SFML,代码行数:8,代码来源:HIDJoystickManager.cpp

示例15: FetchIPAddress

static void FetchIPAddress()
{
	if(publicIPState == IPStateFetching)
		return;

	publicIPState = IPStateFetching;

	const UInt8 bodyBytes[] = {0};
	CFDataRef body = CFDataCreate(kCFAllocatorDefault, bodyBytes, 0);

	CFURLRef url = CFURLCreateWithString(kCFAllocatorDefault, CFSTR("http://icanhazip.com"), NULL);
	CFHTTPMessageRef request = CFHTTPMessageCreateRequest(kCFAllocatorDefault, CFSTR("GET"), url, kCFHTTPVersion1_1);
	CFHTTPMessageSetBody(request, body);

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"

	// Apple suggests the NSURLSession API instead of CFReadStreamCreateForHTTPRequest,
	// But obviously that doesn't really work here

	CFReadStreamRef stream = CFReadStreamCreateForHTTPRequest(kCFAllocatorDefault, request);

#pragma clang diagnostic pop

	CFRelease(body);
	CFRelease(url);
	CFRelease(request);

	CFMutableDataRef responseData = CFDataCreateMutable(kCFAllocatorDefault, 17);
	CFStreamClientContext context = { 0, responseData, NULL, NULL, NULL };

	if(!CFReadStreamSetClient(stream, kCFStreamEventOpenCompleted | kCFStreamEventHasBytesAvailable | kCFStreamEventEndEncountered | kCFStreamEventErrorOccurred, &IPStreamCallback, &context))
	{
		CFRelease(stream);

		publicIPState = IPStateInvalid;
		return;
	}

	// Add to the run loop and open the stream
	CFReadStreamScheduleWithRunLoop(stream, CFRunLoopGetCurrent(), kCFRunLoopCommonModes);

	if(!CFReadStreamOpen(stream))
	{
		CFReadStreamSetClient(stream, 0, NULL, NULL);
		CFReadStreamUnscheduleFromRunLoop(stream, CFRunLoopGetCurrent(), kCFRunLoopCommonModes);
		CFRelease(stream);

		publicIPState = IPStateInvalid;
		return;
	}


	// Run the run loop
	do {
		CFRunLoopRunInMode(kCFRunLoopDefaultMode, 1.0, TRUE);
	} while(publicIPState == IPStateFetching);
}
开发者ID:JustSid,项目名称:extip,代码行数:58,代码来源:server.c


注:本文中的CFRunLoopRunInMode函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。