Skip to content

Instantly share code, notes, and snippets.

@macguru
macguru / ScopedTask.swift
Last active January 19, 2026 12:03
ScopedTask: A wrapper around Task that auto-cancels when going out of scope.
/// A task that is cancelled if goes out of scope, i.e. the last reference on it has been discarded.
public final class ScopedTask<Success: Sendable, Failure: Error>: Sendable {
/// The underlying task
let wrapped: Task<Success, Failure>
/// Wraps a task into a scoped task.
init(wrapping task: Task<Success, Failure>) {
wrapped = task
}
//
// ContentView.swift
// AppleMusicLyricsPlayer
//
// Created by Magesh Sridhar on 2/5/23.
//
import SwiftUI
import AVKit
@lattner
lattner / TaskConcurrencyManifesto.md
Last active March 7, 2026 21:39
Swift Concurrency Manifesto