@@ -9,7 +9,8 @@ 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);
12+ // void* Dispatch_Create_Queue(const char* label, int type);
13+ // void Dispatch_Main();
1314import "C"
1415import (
1516 "math"
@@ -31,6 +32,13 @@ const (
3132 QueuePriorityBackground QueuePriority = math .MinInt16
3233)
3334
35+ type QueueType int
36+
37+ const (
38+ QueueTypeSerial QueueType = 0
39+ QueueTypeConcurrent QueueType = 1
40+ )
41+
3442// Returns the serial dispatch queue associated with the application’s main thread. [Full Topic]
3543//
3644// [Full Topic]: https://developer.apple.com/documentation/dispatch/1452921-dispatch_get_main_queue?language=objc
@@ -75,11 +83,16 @@ func runQueueTask(p C.uintptr_t) {
7583 h .Delete ()
7684}
7785
86+ // Main executes blocks submitted to the main queue.
87+ func Main () {
88+ C .Dispatch_Main ()
89+ }
90+
7891// Creates a new dispatch queue to which blocks can be submitted.
7992//
8093// [Full Topic]: https://developer.apple.com/documentation/dispatch/1453030-dispatch_queue_create?language=objc
81- func CreateQueue (label string , attr uintptr ) Queue {
94+ func CreateQueue (label string , queueType QueueType ) Queue {
8295 cLabel := C .CString (label )
83- p := C .Dispatch_Create_Queue (cLabel , unsafe . Pointer ( attr ))
96+ p := C .Dispatch_Create_Queue (cLabel , C . int ( queueType ))
8497 return Queue {p }
8598}
0 commit comments