D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
self
/
root
/
opt
/
alt
/
ruby34
/
share
/
ri
/
system
/
IO
/
Buffer
/
Filename :
locked-i.ri
back
Copy
U:RDoc::AnyMethod[iI"locked:ETI"IO::Buffer#locked;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [ I"PAllows to process a buffer in exclusive way, for concurrency-safety. While ;TI"Pthe block is performed, the buffer is considered locked, and no other code ;TI"Ncan enter the lock. Also, locked buffer can't be changed with #resize or ;TI"#free.;To:RDoc::Markup::BlankLine o; ; [I"=The following operations acquire a lock: #resize, #free.;T@o; ; [I"GLocking is not thread safe. It is designed as a safety net around ;TI"Qnon-blocking system calls. You can only share a buffer between threads with ;TI",appropriate synchronisation techniques.;T@o:RDoc::Markup::Verbatim; [I" buffer = IO::Buffer.new(4) ;TI"buffer.locked? #=> false ;TI" ;TI"Fiber.schedule do ;TI" buffer.locked do ;TI"> buffer.write(io) # theoretical system call interface ;TI" end ;TI" end ;TI" ;TI"Fiber.schedule do ;TI"G # in `locked': Buffer already locked! (IO::Buffer::LockedError) ;TI" buffer.locked do ;TI"& buffer.set_string("test", 0) ;TI" end ;TI"end;T:@format0: @fileI"io_buffer.c;T:0@omit_headings_from_table_of_contents_below0I"locked { ... } ;T0[ I"();T@+FI"Buffer;TcRDoc::NormalClass00