Documentation for method lock
Documentation for method lock, assembled from the following types:
method lock(IO::Handle: Bool : = False, Bool : = False --> True)
Places an advisory lock on the filehandle. If
X::IO::Lock if lock could not be obtained, otherwise will block until the lock can be placed. If
True will place a shared (read) lock, otherwise will place an exclusive (write) lock. On success, returns
True; fails with
X::IO::Lock if lock cannot be placed (e.g. when trying to place a shared lock on a filehandle opened in write mode or trying to place an exclusive lock on a filehandle opened in read mode).
# One program writes, the other reads, and thanks to locks either# will wait for the other to finish before proceeding to read/write# Writergiven "foo".IO.open(:w)# Readergiven "foo".IO.open
method lock(IO::CatHandle: Bool : = False, Bool : = False --> True)
Acquires the lock. If it is currently not available, waits for it.
my = Lock.new;.lock;