Parent

Methods

File


Public Instance Methods

flock?() click to toggle source

Returns true if another process holds an exclusive lock on the file. Returns false if this is not the case.

If a block of code is passed to this method, it will be run iff this process can obtain an exclusive lock on the file. The block will be run while this lock is held, and the exclusive lock will be released when the method returns.

The exclusive lock is requested in a non-blocking mode. This method will return immediately (and the block will not be executed) if an exclusive lock cannot be obtained.

     # File lib/logging/utils.rb, line 145
145:   def flock?
146:     status = flock(LOCK_EX|LOCK_NB)
147:     case status
148:     when false; true
149:     when 0; block_given? ? yield : false
150:     else
151:       raise SystemCallError, "flock failed with status: #{status}"
152:     end
153:   ensure
154:     flock LOCK_UN
155:   end
flock_sh() click to toggle source

Execute a block in the context of a shared lock on this file. A shared lock will be obtained on the file, the block executed, and the lock released.

     # File lib/logging/utils.rb, line 161
161:   def flock_sh
162:     flock LOCK_SH
163:     yield
164:   ensure
165:     flock LOCK_UN
166:   end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.