summaryrefslogtreecommitdiff
path: root/ractor.h
diff options
context:
space:
mode:
authorKoichi Sasada <ko1@atdot.net>2020-10-19 16:47:32 +0900
committerKoichi Sasada <ko1@atdot.net>2020-10-20 01:05:06 +0900
commit319afed20fba8f9b44611d16e4930260f7b56b86 (patch)
tree39d24da0464a39a2bfbc93f4ab5849945bc6f652 /ractor.h
parent3f97940252a37db6e601b4bb1aa1e87204f769df (diff)
Use language TLS specifier if it is possible.
To access TLS, it is faster to use language TLS specifier instead of using pthread_get/setspecific functions. Original proposal is: Use native thread locals. #3665
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3667
Diffstat (limited to 'ractor.h')
-rw-r--r--ractor.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/ractor.h b/ractor.h
index 4cd89522a7..d3de06b559 100644
--- a/ractor.h
+++ b/ractor.h
@@ -205,7 +205,15 @@ rb_ractor_thread_switch(rb_ractor_t *cr, rb_thread_t *th)
static inline void
rb_ractor_set_current_ec(rb_ractor_t *cr, rb_execution_context_t *ec)
{
+#ifdef RB_THREAD_LOCAL_SPECIFIER
+ #if __APPLE__
+ rb_current_ec_set(ec);
+ #else
+ ruby_current_ec = ec;
+ #endif
+#else
native_tls_set(ruby_current_ec_key, ec);
+#endif
if (cr->threads.running_ec != ec) {
if (0) fprintf(stderr, "rb_ractor_set_current_ec ec:%p->%p\n",