Class: Zold::SyncEntrance
- Inherits:
-
Object
- Object
- Zold::SyncEntrance
- Defined in:
- lib/zold/node/sync_entrance.rb
Overview
The entrance that makes sure only one thread works with a wallet
Instance Method Summary collapse
-
#initialize(entrance, dir, timeout: 30, log: Log::Quiet.new) ⇒ SyncEntrance
constructor
A new instance of SyncEntrance.
-
#push(id, body) ⇒ Object
Always returns an array with a single ID of the pushed wallet.
- #start ⇒ Object
- #to_json ⇒ Object
Constructor Details
#initialize(entrance, dir, timeout: 30, log: Log::Quiet.new) ⇒ SyncEntrance
Returns a new instance of SyncEntrance.
36 37 38 39 40 41 |
# File 'lib/zold/node/sync_entrance.rb', line 36 def initialize(entrance, dir, timeout: 30, log: Log::Quiet.new) @entrance = entrance @dir = dir @timeout = timeout @log = log end |
Instance Method Details
#push(id, body) ⇒ Object
Always returns an array with a single ID of the pushed wallet
54 55 56 57 58 |
# File 'lib/zold/node/sync_entrance.rb', line 54 def push(id, body) Futex.new(File.join(@dir, id), log: @log).open do @entrance.push(id, body) end end |
#start ⇒ Object
47 48 49 50 51 |
# File 'lib/zold/node/sync_entrance.rb', line 47 def start @entrance.start do yield(self) end end |
#to_json ⇒ Object
43 44 45 |
# File 'lib/zold/node/sync_entrance.rb', line 43 def to_json @entrance.to_json end |