Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
IO::Buffer#locked?
() -> bool
locked? → true or false
io_buffer.c
View on GitHub ↗
static VALUE
rb_io_buffer_locked_p(VALUE self)
{
struct rb_io_buffer_view *buffer = get_io_buffer_view(self);
return RBOOL(io_buffer_locked(buffer));
}
If the buffer is locked, its underlying allocation cannot be resized, freed or transferred. Locks are shared with slices and may be nested.
Locking is a lifetime mechanism used to ensure buffers don’t move while being used by a system call or other native operation.
Example
buffer.locked do buffer.write(io) # theoretical system call interface end