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


C++ dispatch_queue_create函数代码示例

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


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

示例1: main

int main(){
    dispatch_queue_t logQueue = dispatch_queue_create("logging file access queue", DISPATCH_QUEUE_SERIAL);
    dispatch_queue_t workQueue = dispatch_queue_create("concurrent work queue", DISPATCH_QUEUE_CONCURRENT);
    
    dispatch_block_t logRequest = ^{  
        logData:
        /* write request meta data on the log */; };
        
    dispatch_block_t handleRendering = ^{  
        while(NONDETERMINISTIC){
            /* do some heavy rendering computations */
            dispatch_async(logQueue, logRequest);
        } };
        
    dispatch_block_t handleFileStorage = ^{  
        storeFile: /*  store file */
        dispatch_async(logQueue, logRequest);
        storage_system_busy = 0; };

    while(1){
        if(storage_system_busy == 0 && NONDETERMINISTIC){ 
            assert(storage_system_busy == 0); // check for possible race conditions
            storage_system_busy = 1;
            dispatch_async(workQueue, handleFileStorage);
        } else if(NONDETERMINISTIC){
            dispatch_async(workQueue, handleRendering);
        }
    }

    return 0;
}
开发者ID:JulienMe,项目名称:G2Q2P,代码行数:31,代码来源:async_server.c

示例2: config

TCController::TCController(TCConfig *_config) :
	config(_config),
	running(false)
{
	// Retain config
	_config->retain();
	
	// Init vars
	mstatus = tccontroller_available;
	running = false;
	socketAccept = 0;
	
	nQueue = 0;
	nBlock = NULL;
	
	buddiesLoaded = false;
	
	timer = 0;
	
	// Get profile avatar
	pavatar = config->get_profile_avatar();
	
	if (!pavatar)
		pavatar = new TCImage(64, 64);
	
	// Get profile name & text
	pname = new TCString(config->get_profile_name());
	ptext = new TCString(config->get_profile_text());
	
	// Alloc queue
	mainQueue = dispatch_queue_create("com.torchat.core.controller.main", DISPATCH_QUEUE_SERIAL);
	socketQueue = dispatch_queue_create("com.torchat.core.controller.socket", DISPATCH_QUEUE_SERIAL);
}
开发者ID:chroniX0,项目名称:torchat-mac,代码行数:33,代码来源:TCController.cpp

示例3: Syslog

void Syslog(char *udid)
{
	operatingQueue = dispatch_queue_create("com.samdmarshall.mobile.syslog.operations", DISPATCH_QUEUE_SERIAL);
	updatelogQueue = dispatch_queue_create("com.samdmarshall.mobile.syslog.updatelog", DISPATCH_QUEUE_SERIAL);
	AttachToSyslog(udid);
	PrintSysLog();
}
开发者ID:K0smas,项目名称:SDMMobileDevice,代码行数:7,代码来源:syslog.c

示例4: init_globals

static void
init_globals(void)
{
    static dispatch_once_t once;
    dispatch_once(&once, ^{
	timerq = dispatch_queue_create("hiem-sipc-timer-q", NULL);
        timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, timerq);
	dispatch_source_set_event_handler(timer, ^{ timer_ev(); } );

	workq = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
	eventq = dispatch_queue_create("heim-ipc.event-queue", NULL);
    });
开发者ID:Henauxg,项目名称:minix,代码行数:12,代码来源:server.c

示例5: CAPlayThrough

void CAPlayThroughHost::CreatePlayThrough(AudioDeviceID input, AudioDeviceID output)
{
	mPlayThrough = new CAPlayThrough(input, output);
    StreamListenerQueue = dispatch_queue_create("com.CAPlayThough.StreamListenerQueue", DISPATCH_QUEUE_SERIAL);
    //if (StreamListenerQueue) dispatch_set_context(StreamListenerQueue, this);
	AddDeviceListeners(input);
}
开发者ID:thepixelheart,项目名称:PixelPusher,代码行数:7,代码来源:CAPlayThrough.cpp

示例6: dispatch_queue_create

void
IOPowerWatcher::setupDarkWake()
{
    IOReturn            ret;
    
    mInDarkWake = false;

    mIOPMqueue = dispatch_queue_create("com.apple.security.IOPowerWatcher", NULL);
    if (mIOPMqueue == NULL)
	return;

    ret = ::IOPMConnectionCreate(CFSTR("IOPowerWatcher"),
				 kIOPMSystemPowerStateCapabilityDisk 
				 | kIOPMSystemPowerStateCapabilityNetwork
				 | kIOPMSystemPowerStateCapabilityAudio 
				 | kIOPMSystemPowerStateCapabilityVideo,
				 &mIOPMconn);
    if (ret != kIOReturnSuccess)
	return;
	
    ret = ::IOPMConnectionSetNotification(mIOPMconn, this,
					  (IOPMEventHandlerType)iopmcallback);
    if (ret != kIOReturnSuccess)
	return;

    ::IOPMConnectionSetDispatchQueue(mIOPMconn, mIOPMqueue);
}
开发者ID:Apple-FOSS-Mirror,项目名称:Security,代码行数:27,代码来源:powerwatch.cpp

示例7: rwsched_dispatch_queue_create

rwsched_dispatch_queue_t
rwsched_dispatch_queue_create(rwsched_tasklet_ptr_t sched_tasklet,
                              const char *label,
                              dispatch_queue_attr_t attr)
{
  struct rwsched_dispatch_queue_s *queue;

  // Validate input paraemters
  RW_CF_TYPE_VALIDATE(sched_tasklet, rwsched_tasklet_ptr_t);
  rwsched_instance_ptr_t instance = sched_tasklet->instance;
  RW_CF_TYPE_VALIDATE(instance, rwsched_instance_ptr_t);

  // Allocate memory for the dispatch queue
  queue = (rwsched_dispatch_queue_t) RW_MALLOC0_TYPE(sizeof(*queue), rwsched_dispatch_queue_t);
  RW_ASSERT_TYPE(queue, rwsched_dispatch_queue_t);

  // If libdispatch is enabled for the entire instance, then call the libdispatch routine
  if (instance->use_libdispatch_only) {
    queue->header.libdispatch_object._dq = dispatch_queue_create(label, attr);
    RW_ASSERT(queue->header.libdispatch_object._dq);

    rwsched_tasklet_ref(sched_tasklet);
    ck_pr_inc_32(&sched_tasklet->counters.queues);

    return queue;
  }

  // Not yet implemented
  RW_CRASH();
  return NULL;
}
开发者ID:RIFTIO,项目名称:RIFT.ware,代码行数:31,代码来源:rwsched_queue.c

示例8: mdns_init

int
mdns_init(void)
{
  DPRINTF(E_DBG, L_MDNS, "Initializing Avahi mDNS\n");

  all_w = NULL;
  all_t = NULL;
  group_entries = NULL;
  browser_list = NULL;

  mdns_sq = dispatch_queue_create("org.forked-daapd.mdns", NULL);
  if (!mdns_sq)
    {
      DPRINTF(E_FATAL, L_MDNS, "mdns_init: Could not create dispatch queue\n");
      return -1;
    }

  dispatch_sync_f(mdns_sq, NULL, mdns_init_task);

  if (!mdns_client)
    goto client_fail;

  return 0;

 client_fail:
  dispatch_release(mdns_sq);

  return -1;
}
开发者ID:Deledrius,项目名称:forked-daapd,代码行数:29,代码来源:mdns_avahi.c

示例9: timer_manager_queue

static
dispatch_queue_t timer_manager_queue() {
    static dispatch_queue_t timer_manager_queue;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        timer_manager_queue = dispatch_queue_create("com.elastos.cloud.ecdev", DISPATCH_QUEUE_SERIAL);
    });
开发者ID:stiartsly,项目名称:eCamera,代码行数:7,代码来源:vsys.c

示例10: do_test

static void do_test(void)
{
	size_t i;
	char buf[1000];

	count_down = COUNT;

	start = dispatch_time(0,0);

	for (i = 0; i < COUNT; i++) {
#ifdef WIN32
		_snprintf(buf, sizeof(buf), "com.example.starfish-node#%ld", i);
#else
		snprintf(buf, sizeof(buf), "com.example.starfish-node#%ld", (long int)i);
#endif
		queues[i] = dispatch_queue_create(buf, NULL);
		dispatch_suspend(queues[i]);
	}

	for (i = 0; i < COUNT; i++) {
		dispatch_async_f(queues[i], queues[i], start_node);
	}

	for (i = 0; i < COUNT; i++) {
		dispatch_resume(queues[i]);
	}
}
开发者ID:RunLoopStudio,项目名称:xdispatch,代码行数:27,代码来源:dispatch_starfish.c

示例11: LOCKED

CF_INLINE void LOCKED(dispatch_block_t work) {
    static dispatch_once_t guard;
    static dispatch_queue_t CFUUIDGlobalDataLock;
    dispatch_once(&guard, ^{
        dispatch_queue_attr_t dqattr = dispatch_queue_attr_make_with_qos_class(DISPATCH_QUEUE_SERIAL, qos_class_main(), 0);
        CFUUIDGlobalDataLock = dispatch_queue_create("com.apple.CFUUID", dqattr);
    });
开发者ID:Design-Complex,项目名称:CFLite,代码行数:7,代码来源:CFUUID.c

示例12: do_test

static void do_test(void)
{
	size_t i;
	char buf[1000];
	dispatch_group_t g = dispatch_group_create();

	for (i = 0; i < QUEUES; i++) {
#ifdef WIN32
		_snprintf(buf, sizeof(buf), "com.example.memoryload-node#%ld", i);
#else
		snprintf(buf, sizeof(buf), "com.example.memoryload-node#%ld", (long int)i);
#endif
		queues[i] = dispatch_queue_create(buf, NULL);
		dispatch_suspend(queues[i]);
	}

	for (i = 0; i < QUEUES; i++) {
		dispatch_group_async_f(g, queues[i], g, start_node);
	}

	dispatch_group_notify_f(g, dispatch_get_main_queue(), NULL, collect);

	for (i = 0; i < QUEUES; i++) {
		dispatch_resume(queues[i]);
		dispatch_release(queues[i]);
	}
}
开发者ID:RunLoopStudio,项目名称:xdispatch,代码行数:27,代码来源:dispatch_memory_use.c

示例13: _CFMachPortQueue

static dispatch_queue_t _CFMachPortQueue() {
    static volatile dispatch_queue_t __CFMachPortQueue = NULL;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        dispatch_queue_attr_t dqattr = dispatch_queue_attr_make_with_qos_class(DISPATCH_QUEUE_SERIAL, QOS_CLASS_BACKGROUND, 0);
        __CFMachPortQueue = dispatch_queue_create("com.apple.CFMachPort", dqattr);
    });
开发者ID:Design-Complex,项目名称:CFLite,代码行数:7,代码来源:CFMachPort.c

示例14: main

int
main()
{
	dispatch_queue_t q[PRIORITIES];
	int i;

#if USE_SET_TARGET_QUEUE
	test_start("Dispatch Priority (Set Target Queue)");
	for(i = 0; i < PRIORITIES; i++) {
		q[i] = dispatch_queue_create(labels[i], NULL);
		test_ptr_notnull("q[i]", q[i]);
		assert(q[i]);
		dispatch_set_target_queue(as_do(q[i]), dispatch_get_global_queue(priorities[i], 0));
		dispatch_queue_set_width(q[i], DISPATCH_QUEUE_WIDTH_MAX_LOGICAL_CPUS); 
	}
#else
	test_start("Dispatch Priority");
	for(i = 0; i < PRIORITIES; i++) {
		q[i] = dispatch_get_global_queue(priorities[i], 0);
	}
#endif
	
	for(i = 0; i < PRIORITIES; i++) {
		submit_work(q[i], &counts[i].count);
	}

	dispatch_main();
}
开发者ID:DrPizza,项目名称:libdispatch,代码行数:28,代码来源:dispatch_priority.c

示例15: USBMuxAgentCreate

USBMuxAgentRef USBMuxAgentCreate() {
	USBMuxAgentRef agent = (USBMuxAgentRef)calloc(1, sizeof(struct USBMuxAgentClass));
	agent->socket = -1;
	agent->isActive = false;
	agent->socketQueue = dispatch_queue_create("com.samdmarshall.sdm_usbmux.socketQueue", NULL);
	return agent;
}
开发者ID:K0smas,项目名称:SDMMobileDevice,代码行数:7,代码来源:usbmuxd.c


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