1 #include <dispatch/dispatch.h>
6 #include <libkern/OSAtomic.h>
8 #include "dispatch_test.h"
11 const int32_t final
= 32;
16 test_start("Dispatch Overcommit");
18 dispatch_queue_attr_t attr
= dispatch_queue_attr_create();
19 test_ptr_notnull("dispatch_queue_attr_create", attr
);
20 dispatch_queue_attr_set_flags(attr
, DISPATCH_QUEUE_OVERCOMMIT
);
23 for (i
= 0; i
< final
; ++i
) {
25 asprintf(&name
, "test.overcommit.%d", i
);
27 dispatch_queue_t queue
= dispatch_queue_create(name
, attr
);
28 test_ptr_notnull("dispatch_queue_create", queue
);
31 dispatch_async(queue
, ^{
32 OSAtomicIncrement32(&count
);
34 test_long("count", count
, final
);