Class: Puppet::Util::Pidlock Private
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Method Summary collapse
- #file_path ⇒ Object private
-
#initialize(lockfile) ⇒ Pidlock
constructor
private
A new instance of Pidlock.
- #lock ⇒ Object private
- #lock_pid ⇒ Object private
- #locked? ⇒ Boolean private
- #mine? ⇒ Boolean private
- #unlock ⇒ Object private
Constructor Details
#initialize(lockfile) ⇒ Pidlock
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Pidlock.
6 7 8 |
# File 'lib/puppet/util/pidlock.rb', line 6 def initialize(lockfile) @lockfile = Puppet::Util::Lockfile.new(lockfile) end |
Instance Method Details
#file_path ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
42 43 44 |
# File 'lib/puppet/util/pidlock.rb', line 42 def file_path @lockfile.file_path end |
#lock ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
19 20 21 22 23 |
# File 'lib/puppet/util/pidlock.rb', line 19 def lock return mine? if locked? @lockfile.lock(Process.pid) end |
#lock_pid ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
33 34 35 36 37 38 39 40 |
# File 'lib/puppet/util/pidlock.rb', line 33 def lock_pid pid = @lockfile.lock_data begin Integer(pid) rescue ArgumentError, TypeError nil end end |
#locked? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
10 11 12 13 |
# File 'lib/puppet/util/pidlock.rb', line 10 def locked? clear_if_stale @lockfile.locked? end |
#mine? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
15 16 17 |
# File 'lib/puppet/util/pidlock.rb', line 15 def mine? Process.pid == lock_pid end |
#unlock ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
25 26 27 28 29 30 31 |
# File 'lib/puppet/util/pidlock.rb', line 25 def unlock if mine? return @lockfile.unlock else false end end |