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


C++ CFRunLoopRun函数代码示例

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


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

示例1: nc_watch

static void
nc_watch(int argc, char **argv)
{
	SCNetworkConnectionStatus	status;

	nc_create_connection(argc, argv, TRUE);

	status = SCNetworkConnectionGetStatus(connection);

	// report initial status
	n_callback = 0;
	nc_callback(connection, status, &n_callback);

	// setup watcher
	if (doDispatch) {
		if (!SCNetworkConnectionSetDispatchQueue(connection, dispatch_get_main_queue())) {
			SCPrint(TRUE, stderr, CFSTR("Unable to schedule watch process: %s\n"), SCErrorString(SCError()));
			exit(1);
		}
	} else {
		if (!SCNetworkConnectionScheduleWithRunLoop(connection, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode)) {
			SCPrint(TRUE, stderr, CFSTR("Unable to schedule watch process: %s\n"), SCErrorString(SCError()));
			exit(1);
		}
	}

	// wait for changes
	CFRunLoopRun();

	nc_release_connection();
	exit(0);
}
开发者ID:alfintatorkace,项目名称:osx-10.9-opensource,代码行数:32,代码来源:nc.c

示例2: hostMonitoringRoutine

static int hostMonitoringRoutine(RTTHREAD ThreadSelf, void *pvUser)
{
    NOREF(ThreadSelf);
    NOREF(pvUser);
    g_RunLoopRef = CFRunLoopGetCurrent();
    AssertReturn(g_RunLoopRef, VERR_INTERNAL_ERROR);

    CFRetain(g_RunLoopRef);

    CFArrayRef watchingArrayRef = CFArrayCreate(NULL,
                                                (const void **)&kStateNetworkGlobalDNSKey,
                                                1, &kCFTypeArrayCallBacks);
    if (!watchingArrayRef)
    {
        CFRelease(g_DnsWatcher);
        return E_OUTOFMEMORY;
    }

    if(SCDynamicStoreSetNotificationKeys(g_store, watchingArrayRef, NULL))
        CFRunLoopAddSource(CFRunLoopGetCurrent(), g_DnsWatcher, kCFRunLoopCommonModes);

    CFRelease(watchingArrayRef);

    RTSemEventSignal(g_DnsInitEvent);

    CFRunLoopRun();

    CFRelease(g_RunLoopRef);

    return VINF_SUCCESS;
}
开发者ID:etiago,项目名称:vbox,代码行数:31,代码来源:HostDnsServiceDarwin.cpp

示例3: threadrun

void* threadrun(void* context){
    // Tell the device manager which devices we want to look for
    CFMutableArrayRef devices = CFArrayCreateMutable(kCFAllocatorDefault, 0, &kCFTypeArrayCallBacks);
    if(devices){
        int vendor = V_CORSAIR;
        int products[] = { P_K65, P_K70, P_K70_NRGB, P_K95, P_K95_NRGB };
        for(uint i = 0; i < sizeof(products) / sizeof(int); i++){
            int product = products[i];
            CFMutableDictionaryRef device = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
            if(device){
                CFDictionarySetValue(device, CFSTR(kIOHIDVendorIDKey), CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &vendor));
                CFDictionarySetValue(device, CFSTR(kIOHIDProductIDKey), CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &product));
                CFArrayAppendValue(devices, device);
                CFRelease(device);
            }
        }
        IOHIDManagerSetDeviceMatchingMultiple(usbmanager, devices);
        CFRelease(devices);
    }

    // Set up device add callback
    IOHIDManagerRegisterDeviceMatchingCallback(usbmanager, usbadd, 0);
    IOHIDManagerScheduleWithRunLoop(usbmanager, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
    IOHIDManagerOpen(usbmanager, kIOHIDOptionsTypeSeizeDevice);

    // Make a new thread to handle key repeats. The OS won't do it for us.
    pthread_create(&keyrepeatthread, 0, krthread, 0);

    // Run the event loop. Existing devices will be detected automatically.
    while(1){
        CFRunLoopRun();
    }
    return 0;
}
开发者ID:jsnel,项目名称:ckb,代码行数:34,代码来源:usb_mac.c

示例4: RunLoopThread

void* RunLoopThread(void* args)
{
    unsigned i;

    InitUSB();

    currentRunLoop = CFRunLoopGetCurrent();

    CFRunLoopTimerContext context = {0, NULL, NULL, NULL, NULL};
    CFRunLoopTimerRef timer = CFRunLoopTimerCreate(kCFAllocatorDefault, 0.1, 0.1, 0, 0, &onTimerFired, &context);
    CFRunLoopAddTimer(currentRunLoop, timer, kCFRunLoopCommonModes);

    // Signal the parent that we are running
    adb_mutex_lock(&start_lock);
    adb_cond_signal(&start_cond);
    adb_mutex_unlock(&start_lock);

    CFRunLoopRun();
    currentRunLoop = 0;

    for (i = 0; i < vendorIdCount; i++) {
        IOObjectRelease(notificationIterators[i]);
    }
    IONotificationPortDestroy(notificationPort);

    usb_cleanup();

    DBG("RunLoopThread done\n");
    return NULL;    
}
开发者ID:Ugryumych,项目名称:r2d2b2g,代码行数:30,代码来源:usb_osx.cpp

示例5: runServer

static void runServer()
{
    IOHIDEventSystemRef eventSystem = IOHIDEventSystemCreate(kCFAllocatorDefault);
    IOHIDNotificationRef notification = NULL;
    
    require(eventSystem, exit);
        
    IOHIDEventSystemOpen(eventSystem, eventCallback, NULL, NULL, 0);
            
    if ( !__serviceNotifications )
        __serviceNotifications = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);

    CFArrayRef services = IOHIDEventSystemCopyMatchingServices(eventSystem, NULL, servicesAddedCallback, NULL, NULL, &notification);
    if ( services ) {
        servicesAddedCallback(NULL, NULL, NULL, services);
        CFRelease(services);
        
    }

    CFRunLoopRun();
exit:
    if ( eventSystem )
        CFRelease(eventSystem);

}
开发者ID:alfintatorkace,项目名称:osx-10.9-opensource,代码行数:25,代码来源:IOHIDEventSystemMonitor.c

示例6: main

int main(int argc, char **argv)
{
    if(CheckArguments(argc, argv))
        return 0;

    KwmInit();
    KWMMach.EventMask = ((1 << kCGEventKeyDown) |
                         (1 << kCGEventKeyUp) |
                         (1 << kCGEventMouseMoved));

    KWMMach.EventTap = CGEventTapCreate(kCGSessionEventTap, kCGHeadInsertEventTap, kCGEventTapOptionDefault, KWMMach.EventMask, CGEventCallback, NULL);
    if(!KWMMach.EventTap || !CGEventTapIsEnabled(KWMMach.EventTap))
        Fatal("ERROR: Could not create event-tap!");

    CFRunLoopAddSource(CFRunLoopGetMain(),
                       CFMachPortCreateRunLoopSource(kCFAllocatorDefault, KWMMach.EventTap, 0),
                       kCFRunLoopCommonModes);

    CGEventTapEnable(KWMMach.EventTap, true);
    CreateWorkspaceWatcher(KWMMach.WorkspaceWatcher);

    // NOTE(koekeishiya): Initialize AXLIB
    // AXLibInit(&AXApplications);
    // AXLibRunningApplications();

    NSApplicationLoad();
    CFRunLoopRun();
    return 0;
}
开发者ID:alessandrostone,项目名称:kwm,代码行数:29,代码来源:kwm.cpp

示例7: main

int main(int argc, char *argv[]) {
    if (argc < 2 || argc > 4) {
        printf("usage: %s [-d] <app> [device_id]\n", argv[0]);
        exit(1);
    }

    
    if (strcmp(argv[1], "-d") == 0) {
        assert(argc == 3 || argc == 4);
        debug = true;
        app_path = argv[2];
        if (argc == 4) {
            device_id = argv[3];
        }
        printf("------ Install phase ------\n");
    } else {
        assert(argc == 2 || argc == 3);
        app_path = argv[1];
        if (argc == 3) {
            device_id = argv[2];
        }
    }

    assert(access(app_path, F_OK) == 0);

    AMDSetLogLevel(5); // otherwise syslog gets flooded with crap
    printf("[....] Waiting for iOS device to be connected\n");

    struct am_device_notification *notify;
    AMDeviceNotificationSubscribe(&device_callback, 0, 0, NULL, &notify); 
    CFRunLoopRun();
}
开发者ID:MaksimKovalyov,项目名称:fruitstrap,代码行数:32,代码来源:fruitstrap.c

示例8: transferData

void transferData(IOUSBInterfaceInterface245 **intf, UInt8 inPipeRef, UInt8 outPipeRef)
{
    IOReturn			err;
    CFRunLoopSourceRef		cfSource;
    int				i;
    
    err = (*intf)->CreateInterfaceAsyncEventSource(intf, &cfSource);
    if (err)
    {
	printf("transferData: unable to create event source, err = %08x\n", err);
	return;
    }
    CFRunLoopAddSource(CFRunLoopGetCurrent(), cfSource, kCFRunLoopDefaultMode);
    for (i=0; i < 12; i++)
	outBuf[i] = 'R';
    err = (*intf)->WritePipeAsync(intf, outPipeRef, outBuf, 12, (IOAsyncCallback1)MyCallBackFunction, (void*)(UInt32)inPipeRef);
    if (err)
    {
	printf("transferData: WritePipeAsyncFailed, err = %08x\n", err);
	CFRunLoopRemoveSource(CFRunLoopGetCurrent(), cfSource, kCFRunLoopDefaultMode);
	return;
    }
    printf("transferData: calling CFRunLoopRun\n");
    CFRunLoopRun();
    printf("transferData: returned from  CFRunLoopRun\n");
    CFRunLoopRemoveSource(CFRunLoopGetCurrent(), cfSource, kCFRunLoopDefaultMode);
}
开发者ID:a-page,项目名称:IOUSBFamily,代码行数:27,代码来源:main.c

示例9: main

int main(int argc, char* argv[]) {
  if (argc != 2) {
    fprintf(stderr, "usage: %s <directory-to-watch>\n", argv[0]);
    exit(1);
  }

  CFStringRef path = CFStringCreateWithCString(
    kCFAllocatorDefault,
    argv[1],
    kCFStringEncodingUTF8
  );

  CFArrayRef pathsToWatch = CFArrayCreate(
    kCFAllocatorDefault,
    (const void **)&path,
    1,
    NULL
  );

  // create stream
  FSEventStreamRef stream = FSEventStreamCreate(
    kCFAllocatorDefault,
    _eventStreamCallback,
    NULL, // context for callback
    pathsToWatch,
    kFSEventStreamEventIdSinceNow,
    0, // latency
    kFSEventStreamCreateFlagFileEvents // this flag was introduced in 10.7
  );

  FSEventStreamScheduleWithRunLoop(stream, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
  FSEventStreamStart(stream);
  CFRunLoopRun();
  return EXIT_SUCCESS; // CFRunLoopRun never returns, we never get here
}
开发者ID:carlwoodward,项目名称:bentoncrossfit,代码行数:35,代码来源:wachdir.c

示例10: main

int main(int argc, const char *argv[]) {

    // Create an event tap to retrieve keypresses.
    CGEventMask eventMask = (CGEventMaskBit(kCGEventKeyDown) | CGEventMaskBit(kCGEventFlagsChanged));
    CFMachPortRef eventTap = CGEventTapCreate(
        kCGSessionEventTap, kCGHeadInsertEventTap, 0, eventMask, CGEventCallback, NULL
    );

    // Exit the program if unable to create the event tap.
    if(!eventTap) {
        fprintf(stderr, "ERROR: Unable to create event tap.\n");
        exit(1);
    }

    // Create a run loop source and add enable the event tap.
    CFRunLoopSourceRef runLoopSource = CFMachPortCreateRunLoopSource(kCFAllocatorDefault, eventTap, 0);
    CFRunLoopAddSource(CFRunLoopGetCurrent(), runLoopSource, kCFRunLoopCommonModes);
    CGEventTapEnable(eventTap, true);
    
    initscr();
    int row, col;
    getmaxyx(stdscr,row,col);
    clear();
    mvprintw(row/2,(col-10)/2,"0.000000%%");   
    refresh();
    CFRunLoopRun();

    return 0;
}
开发者ID:erd0s,项目名称:shit-typing-counter,代码行数:29,代码来源:counter.c

示例11: main

int main (int argc, const char * argv[])
{
	SCNetworkReachabilityRef r = SCNetworkReachabilityCreateWithName(NULL, "api.del.icio.us");
	
	if(r == NULL)
	{
		printf("Error creating reachability reference.\n");
		goto bail;
	}
	
	if(!SCNetworkReachabilitySetCallback(r, my_SCNetworkReachabilityCallBack, NULL))
	{
		printf("Unable to set reachability callback\n");
		goto bail;
	}
	
	if(!SCNetworkReachabilityScheduleWithRunLoop(r, CFRunLoopGetCurrent(), kCFRunLoopCommonModes))
	{
		printf("Unable to schedule run loop monitoring on run loop.\n");
		goto bail;
	}
	
	printf("Starting run loop. Enable and disable network interfaces to fire the callback.\n");
	CFRunLoopRun();
	printf("Run loop stopped\n");
	
	
bail:
	if(r)
		CFRelease(r);
	
    return 0;
}
开发者ID:CarlChenCC,项目名称:examples,代码行数:33,代码来源:main.c

示例12: main

int main (int argc, const char * argv[]) {
	// Show help
	if (argc != 2 || strncmp(argv[1], "-h", 2) == 0) {
		printf("Sleep until a file in or below the watchdir is modified.\n");
		printf("Usage: fsevent_watch /path/to/watchdir\n");
		exit(1);
	}

	// Create event stream
  CFStringRef pathToWatch = CFStringCreateWithCString(kCFAllocatorDefault, argv[1], kCFStringEncodingUTF8);
  CFArrayRef pathsToWatch = CFArrayCreate(NULL, (const void **)&pathToWatch, 1, NULL);
  void *callbackInfo = NULL;
  FSEventStreamRef stream;
  CFAbsoluteTime latency = 0.5;
  stream = FSEventStreamCreate(
               kCFAllocatorDefault,
               callback,
               callbackInfo,
               pathsToWatch,
               kFSEventStreamEventIdSinceNow,
               latency,
               kFSEventStreamCreateFlagNone
  );

	// Add stream to run loop
  FSEventStreamScheduleWithRunLoop(stream, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
	FSEventStreamStart(stream);
	CFRunLoopRun();

	// Exit
	return 2;
}
开发者ID:seanmoon,项目名称:fresher.js,代码行数:32,代码来源:fsevent_watch.c

示例13: main

int main(void) {

   // Prepare MIDI Interface Client/Port for writing MIDI data:
   MIDIClientRef midiclient;
   MIDIPortRef   midiin;
   OSStatus status;
   if (status = MIDIClientCreate(CFSTR("TeStInG"), NULL, NULL, &midiclient)) {
      printf("Error trying to create MIDI Client structure: %d\n", status);
      printf("%s\n", GetMacOSStatusErrorString(status));
      exit(status);
   }
   if (status = MIDIInputPortCreate(midiclient, CFSTR("InPuT"), myReadProc, 
         NULL, &midiin)) {
      printf("Error trying to create MIDI output port: %d\n", status);
      printf("%s\n", GetMacOSStatusErrorString(status));
      exit(status);
   }

   ItemCount nSrcs = MIDIGetNumberOfSources();
   ItemCount iSrc;
   for (iSrc=0; iSrc<nSrcs; iSrc++) {
      MIDIEndpointRef src = MIDIGetSource(iSrc);
      MIDIPortConnectSource(midiin, src, NULL);
   }
   t = lo_address_new(NULL, "7777");

   CFRunLoopRef runLoop;
   runLoop = CFRunLoopGetCurrent();
   CFRunLoopRun();

   return 0;
}
开发者ID:dpiponi,项目名称:Moodler,代码行数:32,代码来源:cbridge.c

示例14: main

int main(int argc, char** argv)
{
    //
    // From https://developer.apple.com/library/mac/qa/qa1340/_index.html
    // I have basically no idea how this works :)
    //
    // notification port allocated by IORegisterForSystemPower
    IONotificationPortRef  notifyPortRef;

    // notifier object, used to deregister later
    io_object_t            notifierObject;
    // this parameter is passed to the callback
    void*                  refCon;

    // register to receive system sleep notifications

    root_port = IORegisterForSystemPower(refCon, &notifyPortRef, SleepCallBack, &notifierObject);
    if (root_port == 0) {
        printf("IORegisterForSystemPower failed\n");
        return 1;
    }

    // add the notification port to the application runloop
    CFRunLoopAddSource(CFRunLoopGetCurrent(), IONotificationPortGetRunLoopSource(notifyPortRef), kCFRunLoopCommonModes);

    /* Start the run loop to receive sleep notifications. Don't call CFRunLoopRun if this code
        is running on the main thread of a Cocoa or Carbon application. Cocoa and Carbon
        manage the main thread's run loop for you as part of their event handling
        mechanisms.
    */
    CFRunLoopRun();

    //Not reached, CFRunLoopRun doesn't return in this case.
    return 0;
}
开发者ID:saelo,项目名称:weesleep,代码行数:35,代码来源:themagic.c

示例15: btstack_thread_func

static void btstack_thread_func(void* data)
{
   RARCH_LOG("[BTstack]: Thread started");

   if (bt_open_ptr())
      return;

#ifdef __APPLE__
   CFRunLoopSourceContext ctx = { 0, 0, 0, 0, 0, 0, 0, 0, 0, btstack_thread_stop };
   btstack_quit_source = CFRunLoopSourceCreate(0, 0, &ctx);
   CFRunLoopAddSource(CFRunLoopGetCurrent(), btstack_quit_source, kCFRunLoopCommonModes);
#endif

   RARCH_LOG("[BTstack]: Turning on...\n");
   bt_send_cmd_ptr(btstack_set_power_mode_ptr, HCI_POWER_ON);

   RARCH_LOG("BTstack: Thread running...\n");
#ifdef __APPLE__
   CFRunLoopRun();
#endif

   RARCH_LOG("[BTstack]: Thread done.\n");

#ifdef __APPLE__
   CFRunLoopSourceInvalidate(btstack_quit_source);
   CFRelease(btstack_quit_source);
#endif
}
开发者ID:matthijsberk,项目名称:RetroArch,代码行数:28,代码来源:btstack_hid.c


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