Skip to content

Commit

Permalink
- fixed leak in CoroutineScheduler.startCoroutine() when pass `CoSc…
Browse files Browse the repository at this point in the history
…ope`.
  • Loading branch information
Olexandr Belozierov committed Feb 1, 2021
1 parent c137153 commit 9c395df
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ extension CoroutineScheduler {
/// - task: The closure that will be executed inside coroutine. If the task throws an error, then the coroutine will be terminated.
public func startCoroutine(in scope: CoScope? = nil, task: @escaping () throws -> Void) {
guard let scope = scope else { return _startCoroutine { try? task() } }
_startCoroutine {
_startCoroutine { [weak scope] in
guard let coroutine = try? Coroutine.current(),
let completion = scope.add(coroutine.cancel) else { return }
let completion = scope?.add(coroutine.cancel) else { return }
try? task()
completion()
}
Expand Down

0 comments on commit 9c395df

Please sign in to comment.