-
Creates a
ComponentLifecycleinstance.Declaration
Swift
public init(configuration: Configuration = .init())Parameters
configurationDefines lifecycle
Configuration -
Starts the provided
LifecycleItemarray. Startup is performed in the order of items provided.Declaration
Swift
public func start(_ callback: @escaping (Error?) -> Void)Parameters
callbackThe handler which is called after the start operation completes. The parameter will be
nilon success and contain theErrorotherwise. -
Starts the provided
LifecycleItemarray and waits (blocking) until a shutdownSignalis captured orshutdownis called on another thread. Startup is performed in the order of items provided.Declaration
Swift
public func startAndWait() throwsParameters
configurationDefines lifecycle
Configuration -
Shuts down the
LifecycleItemarray provided instartorstartAndWait. Shutdown is performed in reverse order of items provided.Declaration
Swift
public func shutdown(_ callback: @escaping (Error?) -> Void = { _ in })Parameters
callbackThe handler which is called after the start operation completes. The parameter will be
nilon success and contain theErrorotherwise. -
Waits (blocking) until shutdown
Signalis captured orshutdownis invoked on another thread.Declaration
Swift
public func wait()
-
Setup a signal trap.
Declaration
Parameters
signalThe signal to trap.
handlerclosure to invoke when the signal is captured.
Return Value
a
DispatchSourceSignalfor the given trap. The source must be cancled by the caller. -
A system signal
See moreDeclaration
Swift
public struct Signal : Equatable, CustomStringConvertible -
Adds a
Taskto aTaskscollection.Declaration
Swift
func register(_ tasks: LifecycleTask...)Parameters
tasksone or more
Tasks. -
Adds a
Taskto aTaskscollection.Declaration
Swift
func register(_ tasks: [LifecycleTask])Parameters
tasksarray of
Tasks. -
Adds a
Taskto aTaskscollection.Declaration
Swift
func register(label: String, start: LifecycleHandler, shutdown: LifecycleHandler)Parameters
labellabel of the item, useful for debugging.
startHandlerto perform the startup.shutdownHandlerto perform the shutdown. -
Adds a
Taskto aTaskscollection.Declaration
Swift
func registerShutdown(label: String, _ handler: LifecycleHandler)Parameters
labellabel of the item, useful for debugging.
handlerHandlerto perform the shutdown. -
See moreLifecycleconfiguration options.Declaration
Swift
public struct Configuration
View on GitHub
Install in Dash
ServiceLifecycle Structure Reference