• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ dispatch_queue_create函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: m_cardIndex

AudioUnitALSA::AudioUnitALSA(int cardIndex, char* cardName)
    : m_cardIndex(cardIndex), m_cardName(cardName), m_pcmOutput(nullptr), m_pcmInput(nullptr)
{
    static dispatch_once_t pred;
    dispatch_once(&pred, ^ {
        g_audioQueue = dispatch_queue_create("org.darlinghw.audiounit", nullptr);
    });
开发者ID:regex-young,项目名称:darling,代码行数:7,代码来源:AudioUnitALSA.cpp


示例17: mf_peer_init

/* Called when a new client connects */
BOOL mf_peer_init(freerdp_peer* client)
{
	client->ContextSize = sizeof(mfPeerContext);
	client->ContextNew = (psPeerContextNew) mf_peer_context_new;
	client->ContextFree = (psPeerContextFree) mf_peer_context_free;

	if (!freerdp_peer_context_new(client))
		return FALSE;
	
	info_event_queue = mf_event_queue_new();
	
	info_queue = dispatch_queue_create("FreeRDP.update.timer", DISPATCH_QUEUE_SERIAL);
	info_timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, info_queue);
	
	if(info_timer)
	{
		//DEBUG_WARN( "created timer\n");
		dispatch_source_set_timer(info_timer, DISPATCH_TIME_NOW, 42ull * NSEC_PER_MSEC, 100ull * NSEC_PER_MSEC);
		dispatch_source_set_event_handler(info_timer, ^{
			//DEBUG_WARN( "dispatch\n");
			mfEvent* event = mf_event_new(MF_EVENT_TYPE_FRAME_TICK);
			mf_event_push(info_event_queue, (mfEvent*) event);}
						  );
		dispatch_resume(info_timer);
	}
开发者ID:LawlietDo,项目名称:FreeRDP,代码行数:26,代码来源:mf_peer.c


示例18: caml_init_vmnet

CAMLprim value
caml_init_vmnet(value v_mode)
{
  CAMLparam1(v_mode);
  CAMLlocal3(v_iface_ref,v_res,v_mac);
  xpc_object_t interface_desc = xpc_dictionary_create(NULL, NULL, 0);
  xpc_dictionary_set_uint64(interface_desc, vmnet_operation_mode_key, Int_val(v_mode));
  uuid_t uuid;
  uuid_generate_random(uuid);
  xpc_dictionary_set_uuid(interface_desc, vmnet_interface_id_key, uuid);
  __block interface_ref iface = NULL;
  __block vmnet_return_t iface_status = 0;
  __block unsigned char *mac = malloc(6);
  if (!mac) caml_raise_out_of_memory ();
  __block unsigned int mtu = 0;
  __block unsigned int max_packet_size = 0;
  dispatch_queue_t if_create_q = dispatch_queue_create("org.openmirage.vmnet.create", DISPATCH_QUEUE_SERIAL);
  dispatch_semaphore_t iface_created = dispatch_semaphore_create(0);
  iface = vmnet_start_interface(interface_desc, if_create_q,
    ^(vmnet_return_t status, xpc_object_t interface_param) { 
      iface_status = status;
      if (status != VMNET_SUCCESS || !interface_param) {
         dispatch_semaphore_signal(iface_created);
         return;
      }
      //printf("mac desc: %s\n", xpc_copy_description(xpc_dictionary_get_value(interface_param, vmnet_mac_address_key)));
      const char *macStr = xpc_dictionary_get_string(interface_param, vmnet_mac_address_key);
      unsigned char lmac[6];
      if (sscanf(macStr, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", &lmac[0], &lmac[1], &lmac[2], &lmac[3], &lmac[4], &lmac[5]) != 6)
        errx(1, "Unexpected MAC address received from vmnet");
      memcpy(mac, lmac, 6);
      mtu = xpc_dictionary_get_uint64(interface_param, vmnet_mtu_key);
      max_packet_size = xpc_dictionary_get_uint64(interface_param, vmnet_max_packet_size_key);
      dispatch_semaphore_signal(iface_created);
    });
开发者ID:avsm,项目名称:ocaml-vmnet,代码行数:35,代码来源:vmnet_stubs.c


示例19: SDMMD_AFCConnectionCreate

SDMMD_AFCConnectionRef SDMMD_AFCConnectionCreate(SDMMD_AMConnectionRef conn) {
	SDMMD_AFCConnectionRef afc = calloc(1, sizeof(struct sdmmd_AFCConnectionClass));
	afc->handle = conn;
	CFStringRef name = CFStringCreateWithFormat(kCFAllocatorDefault, NULL, CFSTR("%s.%s.%s"), "com.samdmarshall.sdmmobiledevice.afc", SDMCFStringGetString((conn->ivars.device)->ivars.unique_device_id), SDMCFStringGetString(SDMGetCurrentDateString()));
	afc->operationQueue = dispatch_queue_create(SDMCFStringGetString(name), NULL);
	afc->operationCount = 0;
	return afc;
}
开发者ID:AgileBits,项目名称:SDMMobileDevice,代码行数:8,代码来源:SDMMD_AFC.c


示例20: dispatch_queue_create

void Noble::setupXpcConnection() {
  this->dispatchQueue = dispatch_queue_create("com.apple.blued", 0);
  this->xpcConnnection = xpc_connection_create_mach_service("com.apple.blued", this->dispatchQueue, XPC_CONNECTION_MACH_SERVICE_PRIVILEGED);

  xpc_connection_set_event_handler(this->xpcConnnection, ^(xpc_object_t event) {
    xpc_retain(event);
    this->handleXpcEvent(event);
  });
开发者ID:phated,项目名称:noble,代码行数:8,代码来源:Noble.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ dispatch_release函数代码示例发布时间:2022-05-30
下一篇:
C++ dispatch_get_global_queue函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap