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 *buffer = NULL;
TypedData_Get_Struct(self, struct rb_io_buffer, &rb_io_buffer_type, buffer);
return RBOOL(buffer->flags & RB_IO_BUFFER_LOCKED);
}
If the buffer is locked, meaning it is inside locked block execution. Locked buffer can’t be resized or freed, and another lock can’t be acquired on it.
Locking is not thread safe, but is a semantic used to ensure buffers don’t move while being used by a system call.
Example
buffer.locked do buffer.write(io) # theoretical system call interface end