From 23a7714343b372234972ef0dacf774d07fe65ced Mon Sep 17 00:00:00 2001 From: Jean Boussier Date: Fri, 24 Nov 2023 13:18:00 +0100 Subject: Refactor and fix the GVL instrumentation API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This entirely changes how it is tested. Rather than to use counters we now record the timeline of events with associated threads which makes it much easier to assert that certains events are only preceded by a specific event, and makes it much easier to debug unexpected timelines. Co-Authored-By: Étienne Barrié Co-Authored-By: JP Camara Co-Authored-By: John Hawthorn --- include/ruby/thread.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'include/ruby') diff --git a/include/ruby/thread.h b/include/ruby/thread.h index f6eea65b70..f11cc19086 100644 --- a/include/ruby/thread.h +++ b/include/ruby/thread.h @@ -243,9 +243,12 @@ typedef struct rb_internal_thread_event_hook rb_internal_thread_event_hook_t; * @param[in] events A set of events that `func` should run. * @param[in] data Passed as-is to `func`. * @return An opaque pointer to the hook, to unregister it later. - * @note This functionality is a noop on Windows. + * @note This functionality is a noop on Windows and WebAssembly. * @note The callback will be called without the GVL held, except for the * RESUMED event. + * @note Callbacks are not guaranteed to be executed on the native threads + * that corresponds to the Ruby thread. To identify which Ruby thread + * the event refers to, you must use `event_data->thread`. * @warning This function MUST not be called from a thread event callback. */ rb_internal_thread_event_hook_t *rb_internal_thread_add_event_hook( @@ -258,7 +261,7 @@ rb_internal_thread_event_hook_t *rb_internal_thread_add_event_hook( * * @param[in] hook. The hook to unregister. * @return Wether the hook was found and unregistered. - * @note This functionality is a noop on Windows. + * @note This functionality is a noop on Windows and WebAssembly. * @warning This function MUST not be called from a thread event callback. */ bool rb_internal_thread_remove_event_hook( -- cgit v1.2.3