From 23444302d9200bcc41ce279a529f73cad63c3f05 Mon Sep 17 00:00:00 2001 From: normal Date: Fri, 4 Jan 2019 13:14:11 +0000 Subject: introduce rb_nogvl C-API to mark ubf as async-signal-safe zlib and bignum both contain unblocking functions which are async-signal-safe and do not require spawning additional threads. We can execute those functions directly in signal handlers without incurring overhead of extra threads, so provide C-API users the ability to deal with that. Other C-API users may have similar need. This flexible API can supercede existing uses of rb_thread_call_without_gvl and rb_thread_call_without_gvl2 by introducing a flags argument to control behavior. Note: this API is NOT finalized. It needs approval from other committers. I prefer shorter name than previous rb_thread_call_without_gvl* functions because my eyes requires big fonts. [Bug #15499] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66712 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- thread_pthread.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'thread_pthread.c') diff --git a/thread_pthread.c b/thread_pthread.c index d8d3184c62..499da0b9ca 100644 --- a/thread_pthread.c +++ b/thread_pthread.c @@ -1542,6 +1542,11 @@ rb_thread_wakeup_timer_thread(int sig) if (ec) { RUBY_VM_SET_TRAP_INTERRUPT(ec); ubf_timer_arm(current); + + /* some ubfs can interrupt single-threaded process directly */ + if (vm->ubf_async_safe && mth->unblock.func) { + (mth->unblock.func)(mth->unblock.arg); + } } } } -- cgit v1.2.1