D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
self
/
root
/
opt
/
alt
/
ruby34
/
share
/
ri
/
system
/
File
/
Filename :
flock-i.ri
back
Copy
U:RDoc::AnyMethod[iI" flock:ETI"File#flock;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"�Locks or unlocks file +self+ according to the given <code>locking_constant</code>, a bitwise OR of the values in the table below.;To; ; [I"$Not available on all platforms.;To; ; [I"�Returns <code>false</code> if <code>File::LOCK_NB</code> is specified and the operation would have blocked; otherwise returns <code>0</code>.;To:RDoc::Markup::Table:@header[I" Constant;TI" Lock;TI"Effect;T:@align[000: @body[ [I"+File::LOCK_EX+;TI"Exclusive;TI"FOnly one process may hold an exclusive lock for +self+ at a time.;T[I"+File::LOCK_NB+;TI"Non-blocking;TI"sNo blocking; may be combined with +File::LOCK_SH+ or +File::LOCK_EX+ using the bitwise OR operator <tt>|</tt>.;T[I"+File::LOCK_SH+;TI"Shared;TI"PMultiple processes may each hold a shared lock for +self+ at the same time.;T[I"+File::LOCK_UN+;TI"Unlock;TI"2Remove an existing lock held by this process.;To; ; [I" Example:;To:RDoc::Markup::Verbatim; [I"�# Update a counter using an exclusive lock. # Don't use File::WRONLY because it truncates the file. File.open('counter', File::RDWR | File::CREAT, 0644) do |f| f.flock(File::LOCK_EX) value = f.read.to_i + 1 f.rewind f.write("#{value}\n") f.flush f.truncate(f.pos) end # Read the counter using a shared lock. File.open('counter', 'r') do |f| f.flock(File::LOCK_SH) f.read end ;T:@format: ruby: @fileI"file.c;T:0@omit_headings_from_table_of_contents_below0I"+flock(locking_constant) -> 0 or false ;T0[ I" (p1);T@1FI" File;TcRDoc::NormalClass00