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 15
15
// ===----------------------------------------------------------------------===//
16
16
#include < cinttypes>
17
17
18
+ #include " swift/Basic/Lazy.h"
18
19
#include " swift/Runtime/Exclusivity.h"
20
+ #include " swift/Runtime/ThreadLocalStorage.h"
19
21
#include " ../runtime/ExclusivityPrivate.h"
20
22
#include " ../runtime/SwiftTLSContext.h"
21
23
22
24
using namespace swift ;
23
25
using namespace swift ::runtime;
24
26
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;
27
32
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 );
29
42
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
+ }
33
47
34
48
// Bring in the concurrency-specific exclusivity code.
35
49
#include " ../runtime/ConcurrencyExclusivity.inc"
Original file line number Diff line number Diff line change 3
3
// REQUIRES: executable_test
4
4
// REQUIRES: concurrency
5
5
6
- // rdar://76038845
7
- // REQUIRES: rdar83064974
8
6
// REQUIRES: concurrency_runtime
9
7
// UNSUPPORTED: back_deployment_runtime
10
8
You can’t perform that action at this time.
0 commit comments