Ejemplo n.º 1
0
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();
}
Ejemplo n.º 2
0
int
main(void)
{
    test_start("Dispatch Reader/Writer Queues");

    dq = dispatch_queue_create("com.apple.libdispatch.test_readsync", NULL);
    assert(dq);

    dispatch_queue_set_width(dq, LONG_MAX);

    dispatch_apply_f(LAPS, dispatch_get_global_queue(0, 0), NULL, apply_fn);

    dispatch_release(as_do(dq));

    dispatch_main();
}