]>
git.saurik.com Git - apple/libdispatch.git/blob - testing/dispatch_test_sync_on_main.c
4 #include <dispatch/dispatch.h>
7 #include <CoreFoundation/CoreFoundation.h>
14 if (global_count
== 20) {
17 uint64_t time
= random() % NSEC_PER_SEC
;
18 printf("Firing timer on main %d\n", ++global_count
);
19 dispatch_after_f(dispatch_time(0, time
), dispatch_get_main_queue(), NULL
, main_work
);
26 dispatch_queue_t dq
= dispatch_queue_create("foo.bar", NULL
);
29 dispatch_async_f(dispatch_get_main_queue(), NULL
, main_work
);
33 dispatch_sync(dispatch_get_main_queue(), ^{
34 printf("Calling sync %d\n", i
);
35 assert(pthread_main_np() == 1);