1 // RUN: %clang_tsan %s -o %t
2 // RUN: %run %t 2>&1 | FileCheck %s --implicit-check-not='ThreadSanitizer'
4 #include <dispatch/dispatch.h>
11 int main(int argc
, const char *argv
[]) {
12 fprintf(stderr
, "Hello world.\n");
14 dispatch_queue_t q
= dispatch_queue_create("my.queue", DISPATCH_QUEUE_SERIAL
);
15 dispatch_semaphore_t sem
= dispatch_semaphore_create(0);
17 const char *buffer
= "buffer";
18 size_t size
= strlen(buffer
);
20 dispatch_data_t data
= dispatch_data_create(buffer
, size
, q
, ^{
21 fprintf(stderr
, "Data destructor.\n");
24 dispatch_semaphore_signal(sem
);
26 dispatch_release(data
);
28 dispatch_semaphore_wait(sem
, DISPATCH_TIME_FOREVER
);
30 data
= dispatch_data_create(buffer
, size
, q
, DISPATCH_DATA_DESTRUCTOR_DEFAULT
);
31 dispatch_release(data
);
33 fprintf(stderr
, "Done.\n");
36 // CHECK: Hello world.
37 // CHECK: Data destructor.