File tree Expand file tree Collapse file tree 2 files changed +20
-8
lines changed
stdlib/public/BackDeployConcurrency Expand file tree Collapse file tree 2 files changed +20
-8
lines changed Original file line number Diff line number Diff line change 1515// ===----------------------------------------------------------------------===//
1616#include < cinttypes>
1717
18+ #include " swift/Basic/Lazy.h"
1819#include " swift/Runtime/Exclusivity.h"
20+ #include " swift/Runtime/ThreadLocalStorage.h"
1921#include " ../runtime/ExclusivityPrivate.h"
2022#include " ../runtime/SwiftTLSContext.h"
2123
2224using namespace swift ;
2325using namespace swift ::runtime;
2426
25- // Thread-local storage used by the back-deployed concurrency library.
26- namespace {
27+ SwiftTLSContext &SwiftTLSContext::get () {
28+ SwiftTLSContext *ctx = static_cast <SwiftTLSContext *>(
29+ SWIFT_THREAD_GETSPECIFIC (SWIFT_RUNTIME_TLS_KEY));
30+ if (ctx)
31+ return *ctx;
2732
28- static thread_local SwiftTLSContext TLSContext;
33+ static OnceToken_t setupToken;
34+ SWIFT_ONCE_F (
35+ setupToken,
36+ [](void *) {
37+ pthread_key_init_np (SWIFT_RUNTIME_TLS_KEY, [](void *pointer) {
38+ delete static_cast <SwiftTLSContext *>(pointer);
39+ });
40+ },
41+ nullptr );
2942
30- } // anonymous namespace
31-
32- SwiftTLSContext &SwiftTLSContext::get () { return TLSContext; }
43+ ctx = new SwiftTLSContext ();
44+ SWIFT_THREAD_SETSPECIFIC (SWIFT_RUNTIME_TLS_KEY, ctx);
45+ return *ctx;
46+ }
3347
3448// Bring in the concurrency-specific exclusivity code.
3549#include " ../runtime/ConcurrencyExclusivity.inc"
Original file line number Diff line number Diff line change 33// REQUIRES: executable_test
44// REQUIRES: concurrency
55
6- // rdar://76038845
7- // REQUIRES: rdar83064974
86// REQUIRES: concurrency_runtime
97// UNSUPPORTED: back_deployment_runtime
108
You can’t perform that action at this time.
0 commit comments