X-Git-Url: https://git.saurik.com/apple/libdispatch.git/blobdiff_plain/00abc8588ccfc6d910a4ae103bbb45112e917d4c..e85f44377864e428703fb21503e29f422c11288f:/testing/dispatch_test_sync_on_main.c?ds=sidebyside diff --git a/testing/dispatch_test_sync_on_main.c b/testing/dispatch_test_sync_on_main.c deleted file mode 100644 index 6adba96..0000000 --- a/testing/dispatch_test_sync_on_main.c +++ /dev/null @@ -1,46 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -int global_count; - -void -main_work(void* ctxt) -{ - if (global_count == 20) { - exit(0); - } - uint64_t time = random() % NSEC_PER_SEC; - printf("Firing timer on main %d\n", ++global_count); - dispatch_after_f(dispatch_time(0, time), dispatch_get_main_queue(), NULL, main_work); -} - - -int main(void) { - global_count = 0; - - dispatch_queue_t dq = dispatch_queue_create("foo.bar", NULL); - dispatch_async(dq, ^{ - - dispatch_async_f(dispatch_get_main_queue(), NULL, main_work); - - int i; - for (i=0; i<5; ++i) { - dispatch_sync(dispatch_get_main_queue(), ^{ - printf("Calling sync %d\n", i); - assert(pthread_main_np() == 1); - if (i==4) { - global_count = 20; - } - }); - } - }); - - //dispatch_main(); - CFRunLoopRun(); - return 0; -}