Module: Bug::ThreadInstrumentation
- Defined in:
- ext/-test-/thread/instrumentation/instrumentation.c
Class Method Summary collapse
- .register_and_unregister_callbacks ⇒ Object
- .register_callback(strict) ⇒ Object
- .unregister_callback ⇒ Object
Class Method Details
.register_and_unregister_callbacks ⇒ Object
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 |
# File 'ext/-test-/thread/instrumentation/instrumentation.c', line 192
static VALUE
thread_register_and_unregister_callback(VALUE thread)
{
rb_internal_thread_event_hook_t * hooks[5];
for (int i = 0; i < 5; i++) {
hooks[i] = rb_internal_thread_add_event_hook(ex_callback, RUBY_INTERNAL_THREAD_EVENT_READY, NULL);
}
if (!rb_internal_thread_remove_event_hook(hooks[4])) return Qfalse;
if (!rb_internal_thread_remove_event_hook(hooks[0])) return Qfalse;
if (!rb_internal_thread_remove_event_hook(hooks[3])) return Qfalse;
if (!rb_internal_thread_remove_event_hook(hooks[2])) return Qfalse;
if (!rb_internal_thread_remove_event_hook(hooks[1])) return Qfalse;
return Qtrue;
}
|
.register_callback(strict) ⇒ Object
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'ext/-test-/thread/instrumentation/instrumentation.c', line 134
static VALUE
thread_register_callback(VALUE thread, VALUE strict)
{
single_hook = rb_internal_thread_add_event_hook(
ex_callback,
RUBY_INTERNAL_THREAD_EVENT_STARTED |
RUBY_INTERNAL_THREAD_EVENT_READY |
RUBY_INTERNAL_THREAD_EVENT_RESUMED |
RUBY_INTERNAL_THREAD_EVENT_SUSPENDED |
RUBY_INTERNAL_THREAD_EVENT_EXITED,
(void *)RTEST(strict)
);
return Qnil;
}
|
.unregister_callback ⇒ Object
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
# File 'ext/-test-/thread/instrumentation/instrumentation.c', line 170
static VALUE
thread_unregister_callback(VALUE thread)
{
if (single_hook) {
rb_internal_thread_remove_event_hook(single_hook);
single_hook = NULL;
}
VALUE events = rb_ary_new_capa(timeline_cursor);
rb_atomic_t cursor;
for (cursor = 0; cursor < timeline_cursor; cursor++) {
VALUE pair = rb_ary_new_capa(2);
rb_ary_push(pair, event_timeline[cursor].thread);
rb_ary_push(pair, event_symbol(event_timeline[cursor].event));
rb_ary_push(events, pair);
}
reset_timeline();
return events;
}
|