You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
add semantics for stopping tasks that have no start handler (#77)
motivation: address shutdown for tasks which allocate resources on construction. before this change, only tasks that have been started are shutdown, this creates an issue when the resources are allocated on construction since the item may not get started at all (for example due to error in earlier task) and thus will never be shutdown and the resources will leak.
changes: add sematics to request shutdown even if not started, and assume this sematics when registering with start: .none or with registerShutdown
@@ -242,12 +257,9 @@ public class ComponentLifecycle: LifecycleTask {
242
257
privateletlogger:Logger
243
258
internalletshutdownGroup=DispatchGroup()
244
259
245
-
privatevarstate=State.idle
260
+
privatevarstate=State.idle([])
246
261
privateletstateLock=Lock()
247
262
248
-
privatevartasks=[LifecycleTask]()
249
-
privatelettasksLock=Lock()
250
-
251
263
/// Creates a `ComponentLifecycle` instance.
252
264
///
253
265
/// - parameters:
@@ -275,7 +287,9 @@ public class ComponentLifecycle: LifecycleTask {
275
287
/// - on: `DispatchQueue` to run the handlers callback on
276
288
/// - callback: The handler which is called after the start operation completes. The parameter will be `nil` on success and contain the `Error` otherwise.
0 commit comments