about summary refs log tree commit diff
path: root/absl/base/internal/thread_identity.cc
diff options
context:
space:
mode:
authorAbseil Team <absl-team@google.com>2018-09-12T18·03-0700
committerGennadiy Civil <misterg@google.com>2018-09-13T17·24-0400
commit8ff1374008259719b54a8cb128ef951c02da164c (patch)
treed6768eeb981f8e3a14668c329336faee20291346 /absl/base/internal/thread_identity.cc
parent02451914b9ad5320f81f56a89f3eef1f8683227c (diff)
Export of internal Abseil changes.
--
821196cfb2a3b943ffdc4c9e75daec92d7ffb28b by Abseil Team <absl-team@google.com>:

Performance improvements

PiperOrigin-RevId: 212668992

--
704858e2e767016bad27d53eec01d9d48e546b23 by Abseil Team <absl-team@google.com>:

Low-level Portability enchancements for Abseil Mutex on WebAssembly.

Emscripten Pthreads do not use signals, so remove use of pthread_sigmask or
other async-signal-safe related handling code.

PiperOrigin-RevId: 212527958

--
be3e38cb4d493b755132d20c8c2d1a51e45d5449 by Jon Cohen <cohenjon@google.com>:

Internal change.

PiperOrigin-RevId: 212523797
GitOrigin-RevId: 821196cfb2a3b943ffdc4c9e75daec92d7ffb28b
Change-Id: I5694e23e4e09364a15dd6fc4e2e3f15e38835687
Diffstat (limited to 'absl/base/internal/thread_identity.cc')
-rw-r--r--absl/base/internal/thread_identity.cc10
1 files changed, 10 insertions, 0 deletions
diff --git a/absl/base/internal/thread_identity.cc b/absl/base/internal/thread_identity.cc
index 678e8568d742..cff9c1b4f4dc 100644
--- a/absl/base/internal/thread_identity.cc
+++ b/absl/base/internal/thread_identity.cc
@@ -68,6 +68,14 @@ void SetCurrentThreadIdentity(
   // NOTE: Not async-safe.  But can be open-coded.
   absl::call_once(init_thread_identity_key_once, AllocateThreadIdentityKey,
                   reclaimer);
+
+#ifdef __EMSCRIPTEN__
+  // Emscripten PThread implementation does not support signals.
+  // See https://kripken.github.io/emscripten-site/docs/porting/pthreads.html
+  // for more information.
+  pthread_setspecific(thread_identity_pthread_key,
+                      reinterpret_cast<void*>(identity));
+#else
   // We must mask signals around the call to setspecific as with current glibc,
   // a concurrent getspecific (needed for GetCurrentThreadIdentityIfPresent())
   // may zero our value.
@@ -81,6 +89,8 @@ void SetCurrentThreadIdentity(
   pthread_setspecific(thread_identity_pthread_key,
                       reinterpret_cast<void*>(identity));
   pthread_sigmask(SIG_SETMASK, &curr_signals, nullptr);
+#endif  // !__EMSCRIPTEN__
+
 #elif ABSL_THREAD_IDENTITY_MODE == ABSL_THREAD_IDENTITY_MODE_USE_TLS
   // NOTE: Not async-safe.  But can be open-coded.
   absl::call_once(init_thread_identity_key_once, AllocateThreadIdentityKey,