Module: ZeevexConcurrency::Delayed::Bindable
- Included in:
- ZeevexConcurrency::Delay, Future, Promise
- Defined in:
- lib/zeevex_concurrency/delayed.rb
Instance Method Summary collapse
- #bind(proccy = nil, &block) ⇒ Object
- #binding ⇒ Object
- #bound? ⇒ Boolean
- #call ⇒ Object
- #execute ⇒ Object
Instance Method Details
#bind(proccy = nil, &block) ⇒ Object
186 187 188 189 190 191 192 193 |
# File 'lib/zeevex_concurrency/delayed.rb', line 186 def bind(proccy = nil, &block) raise "Already bound" if bound? if proccy && block raise ArgumentError, "must supply a callable OR a block or neither, but not both" end raise ArgumentError, "Must provide computation as proc or block" unless (proccy || block) @binding = proccy || block end |
#binding ⇒ Object
182 183 184 |
# File 'lib/zeevex_concurrency/delayed.rb', line 182 def binding @binding end |
#bound? ⇒ Boolean
178 179 180 |
# File 'lib/zeevex_concurrency/delayed.rb', line 178 def bound? !! @binding end |
#call ⇒ Object
203 204 205 |
# File 'lib/zeevex_concurrency/delayed.rb', line 203 def call execute end |
#execute ⇒ Object
195 196 197 198 199 200 201 |
# File 'lib/zeevex_concurrency/delayed.rb', line 195 def execute @exec_mutex.synchronize do return if executed? return if respond_to?(:cancelled?) && cancelled? _execute(binding) end end |