Skip to content

End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

IO::Buffer#locked?

locked? → true or false

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
See also #locked #mapped? #internal? #null? also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2