@@ -34,7 +34,7 @@ struct Locked<T> {
3434 // The Linux implementation of Mutex terminates if `_tryLock()` is called on
3535 // the owning thread. (Other platforms just return `false`.) So, on Linux,
3636 // we also track the thread ID of the owner.
37- let owningThreadID : Atomic < pthread_t ? >
37+ let owningThreadID : Atomic < pid_t >
3838#endif
3939
4040 init ( _ rawValue: consuming sending T) {
@@ -97,9 +97,9 @@ extension Locked {
9797#else
9898 try _storage. mutex. withLock { rawValue in
9999#if os(Linux) || os(Android)
100- _storage. owningThreadID. store ( pthread_self ( ) , ordering: . sequentiallyConsistent)
100+ _storage. owningThreadID. store ( gettid ( ) , ordering: . sequentiallyConsistent)
101101 defer {
102- _storage. owningThreadID. store ( nil , ordering: . sequentiallyConsistent)
102+ _storage. owningThreadID. store ( 0 , ordering: . sequentiallyConsistent)
103103 }
104104#endif
105105 try body ( & rawValue)
@@ -134,7 +134,7 @@ extension Locked {
134134 return result
135135#else
136136#if os(Linux) || os(Android)
137- let tid = pthread_self ( )
137+ let tid = gettid ( )
138138 if _storage. owningThreadID. load ( ordering: . sequentiallyConsistent) == tid {
139139 // This thread already holds the lock.
140140 return nil
@@ -144,7 +144,7 @@ extension Locked {
144144#if os(Linux) || os(Android)
145145 _storage. owningThreadID. store ( tid, ordering: . sequentiallyConsistent)
146146 defer {
147- _storage. owningThreadID. store ( nil , ordering: . sequentiallyConsistent)
147+ _storage. owningThreadID. store ( 0 , ordering: . sequentiallyConsistent)
148148 }
149149#endif
150150 try body ( & rawValue)
0 commit comments