DispatchSource

extension DispatchSource
  • Convenience function to encapsulate creation of a one-off DispatchSourceTimer for different versions of Swift

    Declaration

    Swift

    public static func makeOneOffDispatchSourceTimer(interval: DispatchTimeInterval,
                                                     queue: DispatchQueue,
                                                     block: @escaping () -> Void ) -> DispatchSourceTimer

    Parameters

    interval

    The future DispatchInterval at which to fire the timer

    queue

    The queue on which the timer should perform its block

    block

    The block to invoke when the timer is fired

    Return Value

    The unstarted timer

  • Convenience function to encapsulate creation of a one-off DispatchSourceTimer for different versions of Swift

    Declaration

    Swift

    public static func makeOneOffDispatchSourceTimer(deadline: DispatchTime,
                                                     queue: DispatchQueue,
                                                     block: @escaping () -> Void ) -> DispatchSourceTimer

    Parameters

    deadline

    The time to fire the timer

    queue

    The queue on which the timer should perform its block

    block

    The block to invoke when the timer is fired