@@ -2211,7 +2211,11 @@ class AsyncContextFlags : public FlagSet<uint32_t> {
2211
2211
Kind_width = 8 ,
2212
2212
2213
2213
CanThrow = 8 ,
2214
- ShouldNotDeallocate = 9
2214
+ ShouldNotDeallocate = 9 ,
2215
+
2216
+ // Kind-specific flags should grow down from 31.
2217
+
2218
+ Continuation_IsExecutorSwitchForced = 31 ,
2215
2219
};
2216
2220
2217
2221
explicit AsyncContextFlags (uint32_t bits) : FlagSet(bits) {}
@@ -2238,6 +2242,11 @@ class AsyncContextFlags : public FlagSet<uint32_t> {
2238
2242
FLAGSET_DEFINE_FLAG_ACCESSORS (ShouldNotDeallocate,
2239
2243
shouldNotDeallocateInCallee,
2240
2244
setShouldNotDeallocateInCallee)
2245
+
2246
+ // / See AsyncContinuationFlags::isExecutorSwitchForced.
2247
+ FLAGSET_DEFINE_FLAG_ACCESSORS (Continuation_IsExecutorSwitchForced,
2248
+ continuation_isExecutorSwitchForced,
2249
+ continuation_setIsExecutorSwitchForced)
2241
2250
};
2242
2251
2243
2252
// / Flags passed to swift_continuation_init.
@@ -2247,6 +2256,7 @@ class AsyncContinuationFlags : public FlagSet<size_t> {
2247
2256
CanThrow = 0 ,
2248
2257
HasExecutorOverride = 1 ,
2249
2258
IsPreawaited = 2 ,
2259
+ IsExecutorSwitchForced = 3 ,
2250
2260
};
2251
2261
2252
2262
explicit AsyncContinuationFlags (size_t bits) : FlagSet(bits) {}
@@ -2262,10 +2272,27 @@ class AsyncContinuationFlags : public FlagSet<size_t> {
2262
2272
hasExecutorOverride,
2263
2273
setHasExecutorOverride)
2264
2274
2275
+ // / Whether the switch to the target executor should be forced
2276
+ // / by swift_continuation_await. If this is not set, and
2277
+ // / swift_continuation_await finds that the continuation has
2278
+ // / already been resumed, then execution will continue on the
2279
+ // / current executor. This has no effect in combination with
2280
+ // / pre-awaiting.
2281
+ // /
2282
+ // / Setting this flag when you know statically that you're
2283
+ // / already on the right executor is suboptimal. In particular,
2284
+ // / there's no good reason to set this if you're not also using
2285
+ // / an executor override.
2286
+ FLAGSET_DEFINE_FLAG_ACCESSORS (IsExecutorSwitchForced,
2287
+ isExecutorSwitchForced,
2288
+ setIsExecutorSwitchForced)
2289
+
2265
2290
// / Whether the continuation is "pre-awaited". If so, it should
2266
2291
// / be set up in the already-awaited state, and so resumptions
2267
2292
// / will immediately schedule the continuation to begin
2268
- // / asynchronously.
2293
+ // / asynchronously. The continuation must not be subsequently
2294
+ // / awaited if this is set. The task is immediately treated as
2295
+ // / suspended.
2269
2296
FLAGSET_DEFINE_FLAG_ACCESSORS (IsPreawaited,
2270
2297
isPreawaited,
2271
2298
setIsPreawaited)
0 commit comments