Skip to content

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

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
See also #locked #not! #inspect #null? also in 4.0 · 3.4 · 3.3 · 3.2 · 3.1