Module: Dapp::Dapp::Lock
- Included in:
- Dapp::Dapp
- Defined in:
- lib/dapp/dapp/lock.rb
Instance Method Summary collapse
- #_lock(name) ⇒ Object
-
#lock(name, *_args, default_timeout: 86400, **kwargs, &blk) ⇒ Object
default_timeout 24 hours.
- #locks_dir ⇒ Object
Instance Method Details
#_lock(name) ⇒ Object
8 9 10 11 |
# File 'lib/dapp/dapp/lock.rb', line 8 def _lock(name) @_locks ||= {} @_locks[name] ||= ::Dapp::Dimg::Lock::File.new(locks_dir, name) end |
#lock(name, *_args, default_timeout: 86400, **kwargs, &blk) ⇒ Object
default_timeout 24 hours
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/dapp/dapp/lock.rb', line 14 def lock(name, *_args, default_timeout: 86400, **kwargs, &blk) if dry_run? yield if block_given? else timeout = [:lock_timeout] || default_timeout _lock(name).synchronize( timeout: timeout, on_wait: proc do |&do_wait| log_secondary_process( t(code: 'process.waiting_resouce_lock', data: { name: name }), short: true, &do_wait ) end, **kwargs, &blk ) end end |
#locks_dir ⇒ Object
4 5 6 |
# File 'lib/dapp/dapp/lock.rb', line 4 def locks_dir File.join(self.class.home_dir, "locks") end |