Module: BlockingSleep
- Defined in:
- lib/blocking_sleep.rb,
ext/blocking_sleep/blocking_sleep.c
Overview
BlockingSleep module provides a native blocking sleep that doesn’t release the GVL (Global VM Lock). This is useful for testing thread behavior and GVL interactions.
Constant Summary collapse
- VERSION =
"0.1.0"
Class Method Summary collapse
-
.sleep(seconds) ⇒ Object
Call native sleep() function without releasing GVL.
Class Method Details
.sleep(seconds) ⇒ Object
Call native sleep() function without releasing GVL. This blocks the entire Ruby VM, useful for testing thread behavior.
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'ext/blocking_sleep/blocking_sleep.c', line 8 static VALUE blocking_sleep_sleep(VALUE self, VALUE seconds) { unsigned int sleep_time; // Convert Ruby number to C unsigned int sleep_time = NUM2UINT(seconds); // Call native sleep() - this blocks without releasing GVL sleep(sleep_time); return Qnil; } |