Skip to content

Commit 1ed3720

Browse files
committed
Add comment.
1 parent 8188f31 commit 1ed3720

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

SwiftTask/SwiftTask.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public enum TaskState: String, Printable
2121
}
2222
}
2323

24-
// NOTE: use class instead of struct to pass reference to closures so that future values can be stored
24+
// NOTE: use class instead of struct to pass reference to `_initClosure` to set `pause`/`resume`/`cancel` closures
2525
public class TaskConfiguration
2626
{
2727
public var pause: (Void -> Void)?
@@ -106,11 +106,11 @@ public class Task<Progress, Value, Error>: Printable
106106
///
107107
/// - e.g. Task<P, V, E>(weakified: false, paused: false) { progress, fulfill, reject, configure in ... }
108108
///
109-
/// :param: weakified Weakifies progress/fulfill/reject handlers to let player (inner asynchronous implementation inside initClosure) NOT CAPTURE this created new task. Normally, weakified = false should be set to gain "player -> task" retaining, so that task will be automatically deinited when player is deinited. If weakified = true, task must be manually retained somewhere else, or it will be immediately deinited.
109+
/// :param: weakified Weakifies progress/fulfill/reject handlers to let player (inner asynchronous implementation inside `initClosure`) NOT CAPTURE this created new task. Normally, `weakified = false` should be set to gain "player -> task" retaining, so that task will be automatically deinited when player is deinited. If `weakified = true`, task must be manually retained somewhere else, or it will be immediately deinited.
110110
///
111111
/// :param: paused Flag to invoke `initClosure` immediately or not. If `paused = true`, task's initial state will be `.Paused` and needs to `resume()` in order to start `.Running`. If `paused = false`, `initClosure` will be invoked immediately.
112112
///
113-
/// :param: initClosure e.g. { progress, fulfill, reject, configure in ... }. fulfill(value) and reject(error) handlers must be called inside this closure, where calling progress(progressValue) handler is optional. Also as options, configure.pause/resume/cancel closures can be set to gain control from outside e.g. task.pause()/resume()/cancel(). When using configure, make sure to use weak modifier when appropriate to avoid "task -> player" retaining which often causes retain cycle.
113+
/// :param: initClosure e.g. { progress, fulfill, reject, configure in ... }. `fulfill(value)` and `reject(error)` handlers must be called inside this closure, where calling `progress(progressValue)` handler is optional. Also as options, `configure.pause`/`configure.resume`/`configure.cancel` closures can be set to gain control from outside e.g. `task.pause()`/`task.resume()`/`task.cancel()`. When using `configure`, make sure to use weak modifier when appropriate to avoid "task -> player" retaining which often causes retain cycle.
114114
///
115115
/// :returns: New task.
116116
///
@@ -499,7 +499,7 @@ public class Task<Progress, Value, Error>: Printable
499499
// inside its `initClosure` *immediately*.
500500
//
501501
if isPaused {
502-
self._machine.state = .Running
502+
self._machine.state = .Running // switch temporarily
503503
}
504504

505505
self._performInitClosure?()
@@ -508,7 +508,7 @@ public class Task<Progress, Value, Error>: Printable
508508
// switch back to `.Paused` only if temporary `.Running` has not changed
509509
// (NOTE: `_performInitClosure` sometimes invokes `initClosure`'s `fulfill()`/`reject()` immediately)
510510
if isPaused && self.state == .Running {
511-
self._machine.state = .Paused
511+
self._machine.state = .Paused // switch back
512512
}
513513
}
514514

0 commit comments

Comments
 (0)