dispatch

package
v0.18.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 24, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Rendered for darwin/amd64

Overview

Package dispatch provides an idiomatic Go wrapper over the raw dispatch C-library bindings: opaque handles become typed wrappers with methods, the C symbol prefix is stripped, and OSStatus/kern_return_t results become Go errors.

Index

Constants

View Source
const (
	DISPATCH_AUTORELEASE_FREQUENCY_INHERIT   = raw.DISPATCH_AUTORELEASE_FREQUENCY_INHERIT
	DISPATCH_AUTORELEASE_FREQUENCY_NEVER     = raw.DISPATCH_AUTORELEASE_FREQUENCY_NEVER
	DISPATCH_AUTORELEASE_FREQUENCY_WORK_ITEM = raw.DISPATCH_AUTORELEASE_FREQUENCY_WORK_ITEM
	DISPATCH_BLOCK_ASSIGN_CURRENT            = raw.DISPATCH_BLOCK_ASSIGN_CURRENT
	DISPATCH_BLOCK_BARRIER                   = raw.DISPATCH_BLOCK_BARRIER
	DISPATCH_BLOCK_DETACHED                  = raw.DISPATCH_BLOCK_DETACHED
	DISPATCH_BLOCK_ENFORCE_QOS_CLASS         = raw.DISPATCH_BLOCK_ENFORCE_QOS_CLASS
	DISPATCH_BLOCK_INHERIT_QOS_CLASS         = raw.DISPATCH_BLOCK_INHERIT_QOS_CLASS
	DISPATCH_BLOCK_NO_QOS_CLASS              = raw.DISPATCH_BLOCK_NO_QOS_CLASS
	DISPATCH_WALLTIME_NOW                    = raw.DISPATCH_WALLTIME_NOW
	FILESEC_ACL                              = raw.FILESEC_ACL
	FILESEC_ACL_ALLOCSIZE                    = raw.FILESEC_ACL_ALLOCSIZE
	FILESEC_ACL_RAW                          = raw.FILESEC_ACL_RAW
	FILESEC_GROUP                            = raw.FILESEC_GROUP
	FILESEC_GRPUUID                          = raw.FILESEC_GRPUUID
	FILESEC_MODE                             = raw.FILESEC_MODE
	FILESEC_OWNER                            = raw.FILESEC_OWNER
	FILESEC_UUID                             = raw.FILESEC_UUID
	MPO_CONNECTION_PORT                      = raw.MPO_CONNECTION_PORT
	MPO_CONNECTION_PORT_WITH_PORT_ARRAY      = raw.MPO_CONNECTION_PORT_WITH_PORT_ARRAY
	MPO_EXCEPTION_PORT                       = raw.MPO_EXCEPTION_PORT
	MPO_NOTIFICATION_PORT                    = raw.MPO_NOTIFICATION_PORT
	MPO_PORT                                 = raw.MPO_PORT
	MPO_REPLY_PORT                           = raw.MPO_REPLY_PORT
	MPO_SERVICE_PORT                         = raw.MPO_SERVICE_PORT
	MPO_WEAK_REPLY_PORT                      = raw.MPO_WEAK_REPLY_PORT
	OS_CLOCK_MACH_ABSOLUTE_TIME              = raw.OS_CLOCK_MACH_ABSOLUTE_TIME
	P_ALL                                    = raw.P_ALL
	P_PGID                                   = raw.P_PGID
	P_PID                                    = raw.P_PID
	QOS_CLASS_BACKGROUND                     = raw.QOS_CLASS_BACKGROUND
	QOS_CLASS_DEFAULT                        = raw.QOS_CLASS_DEFAULT
	QOS_CLASS_UNSPECIFIED                    = raw.QOS_CLASS_UNSPECIFIED
	QOS_CLASS_USER_INITIATED                 = raw.QOS_CLASS_USER_INITIATED
	QOS_CLASS_USER_INTERACTIVE               = raw.QOS_CLASS_USER_INTERACTIVE
	QOS_CLASS_UTILITY                        = raw.QOS_CLASS_UTILITY
)

Variables

This section is empty.

Functions

func AfterF added in v0.17.0

func AfterF(when uint64, queue Queue, context_ unsafe.Pointer, work unsafe.Pointer)

func AllowSendSignals added in v0.17.0

func AllowSendSignals(preserve_signum int32) int32

func ApplyF added in v0.17.0

func ApplyF(iterations uint64, queue Queue, context_ unsafe.Pointer, work unsafe.Pointer)

func GetSpecific added in v0.17.0

func GetSpecific(key unsafe.Pointer) unsafe.Pointer

func Main added in v0.17.0

func Main()

func OnceF added in v0.17.0

func OnceF(predicate *int64, context_ unsafe.Pointer, function unsafe.Pointer)

func Time added in v0.17.0

func Time(when uint64, delta int64) uint64

func Walltime added in v0.17.0

func Walltime(when *bsd.Timespec, delta int64) uint64

Types

type Data added in v0.17.0

type Data struct {
	// contains filtered or unexported fields
}

Data wraps the C handle dispatch_data_t.

func WrapData added in v0.17.0

func WrapData(p unsafe.Pointer) Data

WrapData adopts an existing dispatch_data_t handle.

func (Data) CopyRegion added in v0.17.0

func (h Data) CopyRegion(location uint64, offset_ptr *uint64) Data

func (Data) CreateConcat added in v0.17.0

func (h Data) CreateConcat(data2 Data) Data

func (Data) CreateMap added in v0.17.0

func (h Data) CreateMap(buffer_ptr unsafe.Pointer, size_ptr *uint64) Data

func (Data) CreateSubrange added in v0.17.0

func (h Data) CreateSubrange(offset uint64, length uint64) Data

func (Data) GetSize added in v0.17.0

func (h Data) GetSize() uint64

func (Data) Ptr added in v0.17.0

func (h Data) Ptr() unsafe.Pointer

Ptr returns the underlying dispatch_data_t handle.

type DispatchAutoreleaseFrequencyT added in v0.18.0

type DispatchAutoreleaseFrequencyT = raw.DispatchAutoreleaseFrequencyT

type DispatchBlockFlagsT added in v0.18.0

type DispatchBlockFlagsT = raw.DispatchBlockFlagsT

type DispatchDataS added in v0.18.0

type DispatchDataS = raw.DispatchDataS

type DispatchQueueAttrS added in v0.18.0

type DispatchQueueAttrS = raw.DispatchQueueAttrS

type DispatchQueueS added in v0.18.0

type DispatchQueueS = raw.DispatchQueueS

type DispatchSourceTypeT added in v0.18.0

type DispatchSourceTypeT = raw.DispatchSourceTypeT

type FilesecPropertyT added in v0.18.0

type FilesecPropertyT = raw.FilesecPropertyT

type Group added in v0.17.0

type Group struct {
	// contains filtered or unexported fields
}

Group wraps the C handle dispatch_group_t.

func GroupCreate added in v0.17.0

func GroupCreate() Group

func WrapGroup added in v0.17.0

func WrapGroup(p unsafe.Pointer) Group

WrapGroup adopts an existing dispatch_group_t handle.

func (Group) AsyncF added in v0.17.0

func (h Group) AsyncF(queue Queue, context_ unsafe.Pointer, work unsafe.Pointer)

func (Group) Enter added in v0.17.0

func (h Group) Enter()

func (Group) Leave added in v0.17.0

func (h Group) Leave()

func (Group) NotifyF added in v0.17.0

func (h Group) NotifyF(queue Queue, context_ unsafe.Pointer, work unsafe.Pointer)

func (Group) Ptr added in v0.17.0

func (h Group) Ptr() unsafe.Pointer

Ptr returns the underlying dispatch_group_t handle.

func (Group) Wait added in v0.17.0

func (h Group) Wait(timeout uint64) int64

type IdtypeT added in v0.18.0

type IdtypeT = raw.IdtypeT

type Io added in v0.17.0

type Io struct {
	// contains filtered or unexported fields
}

Io wraps the C handle dispatch_io_t.

func WrapIo added in v0.17.0

func WrapIo(p unsafe.Pointer) Io

WrapIo adopts an existing dispatch_io_t handle.

func (Io) Close added in v0.17.0

func (h Io) Close(flags uint64)

func (Io) GetDescriptor added in v0.17.0

func (h Io) GetDescriptor() int32

func (Io) Ptr added in v0.17.0

func (h Io) Ptr() unsafe.Pointer

Ptr returns the underlying dispatch_io_t handle.

func (Io) SetHighWater added in v0.17.0

func (h Io) SetHighWater(high_water uint64)

func (Io) SetInterval added in v0.17.0

func (h Io) SetInterval(interval uint64, flags uint64)

func (Io) SetLowWater added in v0.17.0

func (h Io) SetLowWater(low_water uint64)

type MpoFlagsT added in v0.18.0

type MpoFlagsT = raw.MpoFlagsT

type OS_dispatch_data

type OS_dispatch_data = raw.OS_dispatch_data

type OS_dispatch_group

type OS_dispatch_group = raw.OS_dispatch_group

type OS_dispatch_io

type OS_dispatch_io = raw.OS_dispatch_io

type OS_dispatch_object

type OS_dispatch_object = raw.OS_dispatch_object

type OS_dispatch_queue

type OS_dispatch_queue = raw.OS_dispatch_queue

type OS_dispatch_queue_attr

type OS_dispatch_queue_attr = raw.OS_dispatch_queue_attr

type OS_dispatch_queue_concurrent

type OS_dispatch_queue_concurrent = raw.OS_dispatch_queue_concurrent

type OS_dispatch_queue_global

type OS_dispatch_queue_global = raw.OS_dispatch_queue_global

type OS_dispatch_queue_main

type OS_dispatch_queue_main = raw.OS_dispatch_queue_main

type OS_dispatch_queue_serial

type OS_dispatch_queue_serial = raw.OS_dispatch_queue_serial

type OS_dispatch_queue_serial_executor

type OS_dispatch_queue_serial_executor = raw.OS_dispatch_queue_serial_executor

type OS_dispatch_semaphore

type OS_dispatch_semaphore = raw.OS_dispatch_semaphore

type OS_dispatch_source

type OS_dispatch_source = raw.OS_dispatch_source

type OS_dispatch_workloop

type OS_dispatch_workloop = raw.OS_dispatch_workloop

type Object added in v0.17.0

type Object struct {
	// contains filtered or unexported fields
}

Object wraps the C handle dispatch_object_t.

func WrapObject added in v0.17.0

func WrapObject(p unsafe.Pointer) Object

WrapObject adopts an existing dispatch_object_t handle.

func (Object) Activate added in v0.17.0

func (h Object) Activate()

func (Object) GetContext added in v0.17.0

func (h Object) GetContext() unsafe.Pointer

func (Object) Ptr added in v0.17.0

func (h Object) Ptr() unsafe.Pointer

Ptr returns the underlying dispatch_object_t handle.

func (Object) Release added in v0.17.0

func (h Object) Release()

func (Object) Resume added in v0.17.0

func (h Object) Resume()

func (Object) Retain added in v0.17.0

func (h Object) Retain()

func (Object) SetContext added in v0.17.0

func (h Object) SetContext(context_ unsafe.Pointer)

func (Object) SetFinalizerF added in v0.17.0

func (h Object) SetFinalizerF(finalizer unsafe.Pointer)

func (Object) SetQosClassFloor added in v0.17.0

func (h Object) SetQosClassFloor(qos_class raw.QosClassT, relative_priority int32)

func (Object) SetTargetQueue added in v0.17.0

func (h Object) SetTargetQueue(queue Queue)

func (Object) Suspend added in v0.17.0

func (h Object) Suspend()

type OsClockidT added in v0.18.0

type OsClockidT = raw.OsClockidT

type OsWorkgroup added in v0.17.0

type OsWorkgroup struct {
	// contains filtered or unexported fields
}

OsWorkgroup wraps the C handle os_workgroup_t.

func WrapOsWorkgroup added in v0.17.0

func WrapOsWorkgroup(p unsafe.Pointer) OsWorkgroup

WrapOsWorkgroup adopts an existing os_workgroup_t handle.

func (OsWorkgroup) Ptr added in v0.17.0

func (h OsWorkgroup) Ptr() unsafe.Pointer

Ptr returns the underlying os_workgroup_t handle.

type QosClassT added in v0.18.0

type QosClassT = raw.QosClassT

type Queue added in v0.17.0

type Queue struct {
	// contains filtered or unexported fields
}

Queue wraps the C handle dispatch_queue_t.

func GetCurrentQueue added in v0.17.0

func GetCurrentQueue() Queue

func QueueCreate added in v0.17.0

func QueueCreate(label string, attr QueueAttr) Queue

func QueueCreateWithTarget added in v0.17.0

func QueueCreateWithTarget(label string, attr QueueAttr, target Queue) Queue

func WrapQueue added in v0.17.0

func WrapQueue(p unsafe.Pointer) Queue

WrapQueue adopts an existing dispatch_queue_t handle.

func (Queue) AssertQueue added in v0.17.0

func (h Queue) AssertQueue()

func (Queue) AssertQueueBarrier added in v0.17.0

func (h Queue) AssertQueueBarrier()

func (Queue) AssertQueueNot added in v0.17.0

func (h Queue) AssertQueueNot()

func (Queue) AsyncAndWaitF added in v0.17.0

func (h Queue) AsyncAndWaitF(context_ unsafe.Pointer, work unsafe.Pointer)

func (Queue) AsyncF added in v0.17.0

func (h Queue) AsyncF(context_ unsafe.Pointer, work unsafe.Pointer)

func (Queue) BarrierAsyncAndWaitF added in v0.17.0

func (h Queue) BarrierAsyncAndWaitF(context_ unsafe.Pointer, work unsafe.Pointer)

func (Queue) BarrierAsyncF added in v0.17.0

func (h Queue) BarrierAsyncF(context_ unsafe.Pointer, work unsafe.Pointer)

func (Queue) BarrierSyncF added in v0.17.0

func (h Queue) BarrierSyncF(context_ unsafe.Pointer, work unsafe.Pointer)

func (Queue) GetLabel added in v0.17.0

func (h Queue) GetLabel() string

func (Queue) GetQosClass added in v0.17.0

func (h Queue) GetQosClass(relative_priority_ptr *int32) raw.QosClassT

func (Queue) GetSpecific added in v0.17.0

func (h Queue) GetSpecific(key unsafe.Pointer) unsafe.Pointer

func (Queue) Ptr added in v0.17.0

func (h Queue) Ptr() unsafe.Pointer

Ptr returns the underlying dispatch_queue_t handle.

func (Queue) SetSpecific added in v0.17.0

func (h Queue) SetSpecific(key unsafe.Pointer, context_ unsafe.Pointer, destructor unsafe.Pointer)

func (Queue) SyncF added in v0.17.0

func (h Queue) SyncF(context_ unsafe.Pointer, work unsafe.Pointer)

type QueueAttr added in v0.17.0

type QueueAttr struct {
	// contains filtered or unexported fields
}

QueueAttr wraps the C handle dispatch_queue_attr_t.

func WrapQueueAttr added in v0.17.0

func WrapQueueAttr(p unsafe.Pointer) QueueAttr

WrapQueueAttr adopts an existing dispatch_queue_attr_t handle.

func (QueueAttr) MakeInitiallyInactive added in v0.17.0

func (h QueueAttr) MakeInitiallyInactive() QueueAttr

func (QueueAttr) MakeWithAutoreleaseFrequency added in v0.17.0

func (h QueueAttr) MakeWithAutoreleaseFrequency(frequency raw.DispatchAutoreleaseFrequencyT) QueueAttr

func (QueueAttr) MakeWithQosClass added in v0.17.0

func (h QueueAttr) MakeWithQosClass(qos_class raw.QosClassT, relative_priority int32) QueueAttr

func (QueueAttr) Ptr added in v0.17.0

func (h QueueAttr) Ptr() unsafe.Pointer

Ptr returns the underlying dispatch_queue_attr_t handle.

type QueueGlobal added in v0.17.0

type QueueGlobal struct {
	// contains filtered or unexported fields
}

QueueGlobal wraps the C handle dispatch_queue_global_t.

func GetGlobalQueue added in v0.17.0

func GetGlobalQueue(identifier int64, flags uint64) QueueGlobal

func WrapQueueGlobal added in v0.17.0

func WrapQueueGlobal(p unsafe.Pointer) QueueGlobal

WrapQueueGlobal adopts an existing dispatch_queue_global_t handle.

func (QueueGlobal) Ptr added in v0.17.0

func (h QueueGlobal) Ptr() unsafe.Pointer

Ptr returns the underlying dispatch_queue_global_t handle.

type QueueMain added in v0.17.0

type QueueMain struct {
	// contains filtered or unexported fields
}

QueueMain wraps the C handle dispatch_queue_main_t.

func GetMainQueue added in v0.17.0

func GetMainQueue() QueueMain

func WrapQueueMain added in v0.17.0

func WrapQueueMain(p unsafe.Pointer) QueueMain

WrapQueueMain adopts an existing dispatch_queue_main_t handle.

func (QueueMain) Ptr added in v0.17.0

func (h QueueMain) Ptr() unsafe.Pointer

Ptr returns the underlying dispatch_queue_main_t handle.

type Semaphore added in v0.17.0

type Semaphore struct {
	// contains filtered or unexported fields
}

Semaphore wraps the C handle dispatch_semaphore_t.

func SemaphoreCreate added in v0.17.0

func SemaphoreCreate(value int64) Semaphore

func WrapSemaphore added in v0.17.0

func WrapSemaphore(p unsafe.Pointer) Semaphore

WrapSemaphore adopts an existing dispatch_semaphore_t handle.

func (Semaphore) Ptr added in v0.17.0

func (h Semaphore) Ptr() unsafe.Pointer

Ptr returns the underlying dispatch_semaphore_t handle.

func (Semaphore) Signal added in v0.17.0

func (h Semaphore) Signal() int64

func (Semaphore) Wait added in v0.17.0

func (h Semaphore) Wait(timeout uint64) int64

type Source added in v0.17.0

type Source struct {
	// contains filtered or unexported fields
}

Source wraps the C handle dispatch_source_t.

func SourceCreate added in v0.17.0

func SourceCreate(type_ *raw.DispatchSourceTypeT, handle uint64, mask uint64, queue Queue) Source

func WrapSource added in v0.17.0

func WrapSource(p unsafe.Pointer) Source

WrapSource adopts an existing dispatch_source_t handle.

func (Source) Cancel added in v0.17.0

func (h Source) Cancel()

func (Source) GetData added in v0.17.0

func (h Source) GetData() uint64

func (Source) GetHandle added in v0.17.0

func (h Source) GetHandle() uint64

func (Source) GetMask added in v0.17.0

func (h Source) GetMask() uint64

func (Source) MergeData added in v0.17.0

func (h Source) MergeData(value uint64)

func (Source) Ptr added in v0.17.0

func (h Source) Ptr() unsafe.Pointer

Ptr returns the underlying dispatch_source_t handle.

func (Source) SetCancelHandlerF added in v0.17.0

func (h Source) SetCancelHandlerF(handler unsafe.Pointer)

func (Source) SetEventHandlerF added in v0.17.0

func (h Source) SetEventHandlerF(handler unsafe.Pointer)

func (Source) SetRegistrationHandlerF added in v0.17.0

func (h Source) SetRegistrationHandlerF(handler unsafe.Pointer)

func (Source) SetTimer added in v0.17.0

func (h Source) SetTimer(start uint64, interval uint64, leeway uint64)

func (Source) Testcancel added in v0.17.0

func (h Source) Testcancel() int64

type Timespec

type Timespec = raw.Timespec

type Workloop added in v0.17.0

type Workloop struct {
	// contains filtered or unexported fields
}

Workloop wraps the C handle dispatch_workloop_t.

func WorkloopCreate added in v0.17.0

func WorkloopCreate(label string) Workloop

func WorkloopCreateInactive added in v0.17.0

func WorkloopCreateInactive(label string) Workloop

func WrapWorkloop added in v0.17.0

func WrapWorkloop(p unsafe.Pointer) Workloop

WrapWorkloop adopts an existing dispatch_workloop_t handle.

func (Workloop) Ptr added in v0.17.0

func (h Workloop) Ptr() unsafe.Pointer

Ptr returns the underlying dispatch_workloop_t handle.

func (Workloop) SetAutoreleaseFrequency added in v0.17.0

func (h Workloop) SetAutoreleaseFrequency(frequency raw.DispatchAutoreleaseFrequencyT)

func (Workloop) SetOsWorkgroup added in v0.17.0

func (h Workloop) SetOsWorkgroup(workgroup OsWorkgroup)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL