diff options
author | Jean Boussier <jean.boussier@gmail.com> | 2022-01-27 17:12:22 +0100 |
---|---|---|
committer | Jean Boussier <jean.boussier@gmail.com> | 2022-06-03 15:13:33 +0200 |
commit | 9125374726fbf68c05ee7585d4a374ffc5efc5db (patch) | |
tree | 5f820c00632eb80a336161245baaf9248dd9eb51 /thread_win32.c | |
parent | d142eff6586de0018c9442129201b03c826f2a1e (diff) |
[Feature #18339] GVL Instrumentation API
Ref: https://bugs.ruby-lang.org/issues/18339
Design:
- This tries to minimize the overhead when no hook is registered.
It should only incur an extra unsynchronized boolean check.
- The hook list is protected with a read-write lock as to cause
contention when some hooks are registered.
- The hooks MUST be thread safe, and MUST NOT call into Ruby as they
are executed outside the GVL.
- It's simply a noop on Windows.
API:
```
rb_internal_thread_event_hook_t * rb_internal_thread_add_event_hook(rb_internal_thread_event_callback callback, rb_event_flag_t internal_event, void *user_data);
bool rb_internal_thread_remove_event_hook(rb_internal_thread_event_hook_t * hook);
```
You can subscribe to 3 events:
- READY: called right before attempting to acquire the GVL
- RESUMED: called right after successfully acquiring the GVL
- SUSPENDED: called right after releasing the GVL.
The hooks MUST be threadsafe, as they are executed outside of the GVL, they also MUST NOT call any Ruby API.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/5500
Diffstat (limited to 'thread_win32.c')
-rw-r--r-- | thread_win32.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/thread_win32.c b/thread_win32.c index a8c9b94cd7..2a3656450b 100644 --- a/thread_win32.c +++ b/thread_win32.c @@ -29,6 +29,18 @@ static volatile DWORD ruby_native_thread_key = TLS_OUT_OF_INDEXES; static int w32_wait_events(HANDLE *events, int count, DWORD timeout, rb_thread_t *th); +rb_internal_thread_event_hook_t * +rb_internal_thread_add_event_hook(rb_internal_thread_event_callback callback, rb_event_flag_t internal_event, void *user_data) +{ + // not implemented +} + +bool +rb_internal_thread_remove_event_hook(rb_internal_thread_event_hook_t * hook) +{ + // not implemented +} + RBIMPL_ATTR_NORETURN() static void w32_error(const char *func) |