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: 300, **kwargs, &blk) ⇒ Object
- #lock_path ⇒ 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(lock_path, name) end |
#lock(name, *_args, default_timeout: 300, **kwargs, &blk) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/dapp/dapp/lock.rb', line 13 def lock(name, *_args, default_timeout: 300, **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 |
#lock_path ⇒ Object
4 5 6 |
# File 'lib/dapp/dapp/lock.rb', line 4 def lock_path build_path.join('locks') end |