18
18
#include " swift/Runtime/Concurrency.h"
19
19
20
20
#include " ../CompatibilityOverride/CompatibilityOverride.h"
21
+ #include " ../runtime/ThreadLocalStorage.h"
21
22
#include " swift/Runtime/Atomic.h"
22
23
#include " swift/Runtime/Casting.h"
23
24
#include " swift/Runtime/Once.h"
@@ -180,6 +181,17 @@ class ExecutorTrackingInfo {
180
181
}
181
182
};
182
183
184
+ #ifdef SWIFT_TLS_HAS_RESERVED_PTHREAD_SPECIFIC
185
+ class ActiveTask {
186
+ public:
187
+ static void set (AsyncTask *task) {
188
+ SWIFT_THREAD_SETSPECIFIC (SWIFT_CONCURRENCY_TASK_KEY, task);
189
+ }
190
+ static AsyncTask *get () {
191
+ return (AsyncTask *)SWIFT_THREAD_GETSPECIFIC (SWIFT_CONCURRENCY_TASK_KEY);
192
+ }
193
+ };
194
+ #else
183
195
class ActiveTask {
184
196
// / A thread-local variable pointing to the active tracking
185
197
// / information about the current thread, if any.
@@ -191,12 +203,13 @@ class ActiveTask {
191
203
};
192
204
193
205
// / Define the thread-locals.
194
- SWIFT_RUNTIME_DECLARE_THREAD_LOCAL (
195
- Pointer<ExecutorTrackingInfo>,
196
- ExecutorTrackingInfo::ActiveInfoInThread);
197
206
SWIFT_RUNTIME_DECLARE_THREAD_LOCAL (
198
207
Pointer<AsyncTask>,
199
208
ActiveTask::Value);
209
+ #endif
210
+ SWIFT_RUNTIME_DECLARE_THREAD_LOCAL (
211
+ Pointer<ExecutorTrackingInfo>,
212
+ ExecutorTrackingInfo::ActiveInfoInThread);
200
213
201
214
} // end anonymous namespace
202
215
0 commit comments