1
- # Advanced isolation checking for SerialExecutor
1
+ # Advanced custom isolation checking for SerialExecutor
2
2
3
- * Proposal: [ SE-NNNN] ( NNNN-advanced-isolation-checking-for-serialexecutor.md )
3
+ * Proposal: [ SE-NNNN] ( NNNN-advanced-custom- isolation-checking-for-serialexecutor.md )
4
4
* Author: [ Konrad 'ktoso' Malawski] ( https://github.com/ktoso )
5
5
* Review Manager: ???
6
6
* Status: ** Work in Progress**
@@ -113,7 +113,7 @@ Specific use-cases of this API include `DispatchSerialQueue`, which would be abl
113
113
// Dispatch
114
114
115
115
extension DispatchSerialQueue {
116
- public func checkIsolated () {
116
+ public func checkIsolated (message : String ) {
117
117
dispatchPrecondition (condition : .onQueue (self )) // existing Dispatch API
118
118
}
119
119
}
@@ -131,7 +131,9 @@ This means that the following code snippet, while a bit unusual remains correct
131
131
actor Worker {
132
132
var number: Int
133
133
134
- nonisolated func canOnlyCallMeWhileIsolatedOnThisInstance () -> Int {
134
+ nonisolated func canOnlyCallMeWhileIsolatedOnThisInstance () -> Int {
135
+ self .preconditionIsolated (" This method must be called while isolated to \( self ) " )
136
+
135
137
return self .assumeIsolated { // () throws -> Int
136
138
// suspensions are not allowed in this closure.
137
139
@@ -168,7 +170,7 @@ The custom heurystics that are today part of the Swift Concurrency runtime to de
168
170
```swift
169
171
// concurrency runtime pseudo-code
170
172
if expectedExecutor.isMainActor () {
171
- globalMainActor .checkIsolated ()
173
+ expectedExecutor .checkIsolated (message : message )
172
174
}
173
175
```
174
176
0 commit comments