summaryrefslogtreecommitdiff
path: root/thread_pthread.c
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-01-04 12:53:06 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-01-04 12:53:06 +0000
commit9e66910b3bd85de32e95cf019ed285a36aecfd9e (patch)
tree1a31f01ea772012d0afe456ae405c8783263e620 /thread_pthread.c
parent79aef1272e877b67b15b00a9cded806845556a0f (diff)
downloadruby-9e66910b3bd85de32e95cf019ed285a36aecfd9e.tar.gz
thread.c (call_without_gvl): spawn thread for UBF iff single-threaded
We need another native thread to call some unblocking functions which aren't RUBY_UBF_IO or RUBY_UBF_PROCESS. Instead of a permanent thread in <= 2.5, we can now rely on the thread cache feature to perform interrupts. [ruby-core:90865] [Bug #15499] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66708 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread_pthread.c')
-rw-r--r--thread_pthread.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/thread_pthread.c b/thread_pthread.c
index e074a854f5..d8d3184c62 100644
--- a/thread_pthread.c
+++ b/thread_pthread.c
@@ -2206,4 +2206,23 @@ timer_pthread_fn(void *p)
return 0;
}
#endif /* UBF_TIMER_PTHREAD */
+
+static VALUE
+ubf_caller(const void *ignore)
+{
+ rb_thread_sleep_forever();
+
+ return Qfalse;
+}
+
+/*
+ * Called if and only if one thread is running, and
+ * the unblock function is NOT async-signal-safe
+ * This assumes USE_THREAD_CACHE is true for performance reasons
+ */
+static VALUE
+rb_thread_start_unblock_thread(void)
+{
+ return rb_thread_create(ubf_caller, 0);
+}
#endif /* THREAD_SYSTEM_DEPENDENT_IMPLEMENTATION */