Contents

CMTimebaseAddTimerDispatchSource(_:timerSource:)

Adds the timer dispatch source to the list of timers the timebase manages.

Declaration

func CMTimebaseAddTimerDispatchSource(_ timebase: CMTimebase, timerSource: dispatch_source_t) -> OSStatus

Discussion

You must create the timer source by calling dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, some_dispatch_queue) and associate an event handler with it from dispatch_source_set_event_handler(timerSource, some_handler_block) or dispatch_source_set_event_handler_f(timerSource, some_handler_function). Call dispatch_resume(timerSource) because the system creates dispatch sources in a suspended state.

The timebase retains the timer source, and maintains its start time according to the CMTime set using CMTimebaseSetTimerDispatchSourceNextFireTime(_:timerSource:fireTime:flags:). Until the first call to CMTimebaseSetTimerDispatchSourceNextFireTime(_:timerSource:fireTime:flags:), the system sets the start time to DISPATCH_TIME_FOREVER.

For more information on dispatch sources, see Dispatch Sources.

See Also

Interacting with Timers