]>
git.saurik.com Git - apple/libdispatch.git/blob - testing/dispatch_readsync.c
1 #include <dispatch/dispatch.h>
8 #include "dispatch_test.h"
13 static size_t r_count
= LAPS
;
14 static size_t w_count
= LAPS
/ INTERVAL
;
17 writer(void *ctxt
__attribute__((unused
)))
27 reader(void *ctxt
__attribute__((unused
)))
29 if (__sync_sub_and_fetch(&r_count
, 1) == 0) {
41 test_start("Dispatch Reader/Writer Queues");
43 dq
= dispatch_queue_create("com.apple.libdispatch.test_readsync", NULL
);
46 dispatch_queue_set_width(dq
, LONG_MAX
);
48 dispatch_apply(LAPS
, dispatch_get_concurrent_queue(0), ^(size_t idx
) {
49 dispatch_sync_f(dq
, NULL
, reader
);
52 dispatch_barrier_async_f(dq
, NULL
, writer
);