# \#task-local

**URL:** https://forums.swift.org/tag/task-local/776.md

[Latest](https://forums.swift.org/latest.md) · [Categories](https://forums.swift.org/categories.md) · [Tags](https://forums.swift.org/tags.md)

---

## [Global actor as TaskLocal](https://forums.swift.org/t/global-actor-as-tasklocal/87303)

<div class="topic-metadata">

**Author:** [@soumyamahunt](https://forums.swift.org/u/soumyamahunt)\
**Replies:** 18\
**Last updated:** [June 23, 2026, 8:21am UTC](https://forums.swift.org/t/global-actor-as-tasklocal/87303 "2026-06-23T08:21:26Z")

</div>

In my code base I am using a global actor across my code base and using swift testing to tests various parts. Swift tests is configured to run tasks in parallel. I noticed some of my tests are flakey and failing randoml…

---

## [\[Pitch\] Structured Task Cancellation Tokens](https://forums.swift.org/t/pitch-structured-task-cancellation-tokens/80355)

<div class="topic-metadata">

**Author:** [@mi11ion](https://forums.swift.org/u/mi11ion)\
**Replies:** 17\
**Last updated:** [June 17, 2025, 8:11pm UTC](https://forums.swift.org/t/pitch-structured-task-cancellation-tokens/80355 "2025-06-17T20:11:05Z")

</div>

Hello This is a pitch addressing a significant limitation in Swift's concurrency system: the current binary cancellation model provides no context about why a task was cancelled, making it impossible to implement differ…

---

## [TaskLocal loose values when using with RunLoop](https://forums.swift.org/t/tasklocal-loose-values-when-using-with-runloop/72830)

<div class="topic-metadata">

**Author:** [@NeonTetra](https://forums.swift.org/u/NeonTetra)\
**Replies:** 2\
**Last updated:** [July 4, 2024, 3:18am UTC](https://forums.swift.org/t/tasklocal-loose-values-when-using-with-runloop/72830 "2024-07-04T03:18:46Z")

</div>

I'm trying to implment SerialExecutor based on RunLoop. So I can manage old non GCD models to the actor world. ( such as CoreLocation ) What I've found is that sometimes. my RunLoop thead jumps to the strange stack poin…

---

## [XCTest.setUp()/tearDown() vs TaskLocal.withValue()](https://forums.swift.org/t/xctest-setup-teardown-vs-tasklocal-withvalue/62802)

<div class="topic-metadata">

**Author:** [@Nickolas\_Pohilets](https://forums.swift.org/u/Nickolas_Pohilets)\
**Replies:** 2\
**Last updated:** [April 13, 2023, 9:55pm UTC](https://forums.swift.org/t/xctest-setup-teardown-vs-tasklocal-withvalue/62802 "2023-04-13T21:55:01Z")

</div>

I have a test where I'm using TaskLocal.withValue() to configure reproducible testing environment. I end up with code like this: class MyTest: XCTestCase { let testEnv = TestEnvironment() func testZero() {…

---

## [Availability of TaskLocal](https://forums.swift.org/t/availability-of-tasklocal/62928)

<div class="topic-metadata">

**Author:** [@Nickolas\_Pohilets](https://forums.swift.org/u/Nickolas_Pohilets)\
**Replies:** 1\
**Last updated:** [February 3, 2023, 11:36am UTC](https://forums.swift.org/t/availability-of-tasklocal/62928 "2023-02-03T11:36:12Z")

</div>

I'm getting a crash on iOS 14.2.0 when app tries to access a @TaskLocal variable: public class Clock { @TaskLocal public static var current: Clock = SystemClock() public var now: Date { fata…
