diff options
author | Koichi Sasada <[email protected]> | 2024-02-20 19:09:23 +0900 |
---|---|---|
committer | Koichi Sasada <[email protected]> | 2024-02-21 15:38:29 +0900 |
commit | d578684989fd2d75f086a259719e3eb0fe57ccb2 (patch) | |
tree | 182d720a6c0a63a7bcc1f6c48c276d082d074c05 /include/ruby/thread.h | |
parent | 91cb30353178004ba57acacf1c39d9c02beff86e (diff) |
`rb_thread_lock_native_thread()`
Introduce `rb_thread_lock_native_thread()` to allocate dedicated
native thread to the current Ruby thread for M:N threads.
This C API is similar to Go's `runtime.LockOSThread()`.
Accepted at https://github.com/ruby/dev-meeting-log/blob/master/2023/DevMeeting-2023-08-24.md
(and missed to implement on Ruby 3.3.0)
Diffstat (limited to 'include/ruby/thread.h')
-rw-r--r-- | include/ruby/thread.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/include/ruby/thread.h b/include/ruby/thread.h index f01d276a29..337f477fd0 100644 --- a/include/ruby/thread.h +++ b/include/ruby/thread.h @@ -191,6 +191,19 @@ void *rb_nogvl(void *(*func)(void *), void *data1, #define RUBY_CALL_WO_GVL_FLAG_SKIP_CHECK_INTS_ /** + * Declare the current Ruby thread should acquire a dedicated + * native thread on M:N thread scheduler. + * + * If a C extension (or a library which the extension relies on) should + * keep to run on a native thread (e.g. using thread-local-storage), + * this function allocates a dedicated native thread for the thread. + * + * @return `false` if the thread already running on a dedicated native + * thread. Otherwise `true`. + */ +bool rb_thread_lock_native_thread(void); + +/** * Triggered when a new thread is started. * * @note The callback will be called *without* the GVL held. |