Class: Wiris::FileLock
- Inherits:
-
Object
- Object
- Wiris::FileLock
- Defined in:
- lib/src-generic/FileLock.rb
Constant Summary collapse
- TIMEOUT =
5000
- WAIT =
100
Class Method Summary collapse
Instance Method Summary collapse
- #file ⇒ Object
-
#initialize(file) ⇒ FileLock
constructor
A new instance of FileLock.
- #release ⇒ Object
Constructor Details
#initialize(file) ⇒ FileLock
Returns a new instance of FileLock.
11 12 13 |
# File 'lib/src-generic/FileLock.rb', line 11 def initialize(file) @file = file end |
Class Method Details
.getLock(filename, wait = 500, remaining = 0) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/src-generic/FileLock.rb', line 15 def self.getLock(filename, wait = 500, remaining = 0) # Time in milliseconds starwait = (Time.now.to_f*1000).to_i file = File.new(filename + ".lock", "w+") return FileLock.new(file) end |
Instance Method Details
#file ⇒ Object
7 8 9 |
# File 'lib/src-generic/FileLock.rb', line 7 def file @file end |
#release ⇒ Object
22 23 24 25 |
# File 'lib/src-generic/FileLock.rb', line 22 def release() file.close File.delete(file) end |