Skip to content

Commit 2f03936

Browse files
committed
feat: add isolation inheritance
1 parent 4d3a8e4 commit 2f03936

File tree

2 files changed

+84
-2
lines changed

2 files changed

+84
-2
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<Scheme
3+
LastUpgradeVersion = "1600"
4+
version = "1.7">
5+
<BuildAction
6+
parallelizeBuildables = "YES"
7+
buildImplicitDependencies = "YES"
8+
buildArchitectures = "Automatic">
9+
<BuildActionEntries>
10+
<BuildActionEntry
11+
buildForTesting = "YES"
12+
buildForRunning = "YES"
13+
buildForProfiling = "YES"
14+
buildForArchiving = "YES"
15+
buildForAnalyzing = "YES">
16+
<BuildableReference
17+
BuildableIdentifier = "primary"
18+
BlueprintIdentifier = "Deadline"
19+
BuildableName = "Deadline"
20+
BlueprintName = "Deadline"
21+
ReferencedContainer = "container:">
22+
</BuildableReference>
23+
</BuildActionEntry>
24+
</BuildActionEntries>
25+
</BuildAction>
26+
<TestAction
27+
buildConfiguration = "Debug"
28+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
29+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
30+
shouldUseLaunchSchemeArgsEnv = "YES"
31+
shouldAutocreateTestPlan = "YES">
32+
<Testables>
33+
<TestableReference
34+
skipped = "NO">
35+
<BuildableReference
36+
BuildableIdentifier = "primary"
37+
BlueprintIdentifier = "DeadlineTests"
38+
BuildableName = "DeadlineTests"
39+
BlueprintName = "DeadlineTests"
40+
ReferencedContainer = "container:">
41+
</BuildableReference>
42+
</TestableReference>
43+
</Testables>
44+
</TestAction>
45+
<LaunchAction
46+
buildConfiguration = "Debug"
47+
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
48+
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
49+
launchStyle = "0"
50+
useCustomWorkingDirectory = "NO"
51+
ignoresPersistentStateOnLaunch = "NO"
52+
debugDocumentVersioning = "YES"
53+
debugServiceExtension = "internal"
54+
allowLocationSimulation = "YES">
55+
</LaunchAction>
56+
<ProfileAction
57+
buildConfiguration = "Release"
58+
shouldUseLaunchSchemeArgsEnv = "YES"
59+
savedToolIdentifier = ""
60+
useCustomWorkingDirectory = "NO"
61+
debugDocumentVersioning = "YES">
62+
<MacroExpansion>
63+
<BuildableReference
64+
BuildableIdentifier = "primary"
65+
BlueprintIdentifier = "Deadline"
66+
BuildableName = "Deadline"
67+
BlueprintName = "Deadline"
68+
ReferencedContainer = "container:">
69+
</BuildableReference>
70+
</MacroExpansion>
71+
</ProfileAction>
72+
<AnalyzeAction
73+
buildConfiguration = "Debug">
74+
</AnalyzeAction>
75+
<ArchiveAction
76+
buildConfiguration = "Release"
77+
revealArchiveInOrganizer = "YES">
78+
</ArchiveAction>
79+
</Scheme>

Sources/Deadline/Deadline.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,16 @@ public func withDeadline<C, R>(
7373
until instant: C.Instant,
7474
tolerance: C.Instant.Duration? = nil,
7575
clock: C,
76+
isolation: isolated (any Actor)? = #isolation,
7677
operation: @Sendable () async throws -> R
7778
) async throws -> R where C: Clock, R: Sendable {
7879

7980
// NB: This is safe to use, because the closure will not escape the context of this function.
8081
let result = await withoutActuallyEscaping(operation) { operation in
8182
await withTaskGroup(
8283
of: DeadlineState<R>.self,
83-
returning: Result<R, any Error>.self
84+
returning: Result<R, any Error>.self,
85+
isolation: isolation
8486
) { taskGroup in
8587

8688
taskGroup.addTask {
@@ -191,7 +193,8 @@ public func withDeadline<C, R>(
191193
public func withDeadline<R>(
192194
until instant: ContinuousClock.Instant,
193195
tolerance: ContinuousClock.Instant.Duration? = nil,
196+
isolation: isolated (any Actor)? = #isolation,
194197
operation: @Sendable () async throws -> R
195198
) async throws -> R where R: Sendable {
196-
try await withDeadline(until: instant, tolerance: tolerance, clock: ContinuousClock(), operation: operation)
199+
try await withDeadline(until: instant, tolerance: tolerance, clock: ContinuousClock(), isolation: isolation, operation: operation)
197200
}

0 commit comments

Comments
 (0)