Skip to content

Commit 450339a

Browse files
committed
dispatch: Add CreateQueue
1 parent e468a64 commit 450339a

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

dispatch/queue.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ package dispatch
99
// void Dispatch_Release(void* queue);
1010
// void Dispatch_Async(void* queue, uintptr_t task);
1111
// void Dispatch_Sync(void* queue, uintptr_t task);
12+
// void* Dispatch_Create_Queue(const char* label, void* attr);
1213
import "C"
1314
import (
1415
"math"
@@ -73,3 +74,12 @@ func runQueueTask(p C.uintptr_t) {
7374
task()
7475
h.Delete()
7576
}
77+
78+
// Creates a new dispatch queue to which blocks can be submitted.
79+
//
80+
// [Full Topic]: https://developer.apple.com/documentation/dispatch/1453030-dispatch_queue_create?language=objc
81+
func CreateQueue(label string, attr uintptr) Queue {
82+
cLabel := C.CString(label)
83+
p := C.Dispatch_Create_Queue(cLabel, unsafe.Pointer(attr))
84+
return Queue{p}
85+
}

dispatch/queue.m

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,9 @@ void Dispatch_Sync(void* queue, uintptr_t task) {
3131
dispatch_sync((dispatch_queue_t)queue, ^{
3232
runQueueTask(task);
3333
});
34-
}
34+
}
35+
36+
void* Dispatch_Create_Queue(const char* label, void* attr) {
37+
dispatch_queue_t queue = dispatch_queue_create(label, attr);
38+
return queue;
39+
}

0 commit comments

Comments
 (0)