Timer

public struct Timer: FileDescriptor

Timer is a file descriptor associated with a timer. See timerfd_create(2) for details.

  • The file descriptor for this timer.

    Declaration

    Swift

    public let fileDescriptor: Int32
  • Creates a timer using the specified clock and configured with the specified flags. See timerfd_create(2) for details.

    Declaration

    Swift

    public init(using clock: Clock = .realTime, flags: Flags = []) throws
  • Sets the timer to trigger on the initial delay, and then at the specified interval. Returns the previously set timer delays.

    Declaration

    Swift

    public func set(initial: TimeInterval, thenEach interval: TimeInterval = 0, flags: SetFlags = []) throws -> (initial: TimeInterval, interval: TimeInterval)
  • Unsets the timer, so that it doesn’t trigger anymore. Returns the previously set timer delays.

    Declaration

    Swift

    public func unset() throws -> (initial: TimeInterval, interval: TimeInterval)
  • Returns the currently set timer delays.

    Declaration

    Swift

    public func get() throws -> (initial: TimeInterval, interval: TimeInterval)
  • Returns the number of times the timer expired since the last call.

    Declaration

    Swift

    public func expirations() throws -> UInt64
  • Releases the resources for this file descriptor.

    Declaration

    Swift

    public func close() throws
  • The type of clock to use for the timer.

    See more

    Declaration

    Swift

    public enum Clock
  • The flags to configure the timer file descriptor.

    See more

    Declaration

    Swift

    public struct Flags: OptionSet
  • The flags to configure how the delays set for the timer should be interpreted.

    See more

    Declaration

    Swift

    public struct SetFlags: OptionSet