Module: Atig::Db::Transaction
Instance Method Summary collapse
Methods included from ExceptionUtil
Instance Method Details
#debug(s) ⇒ Object
40 41 42 43 44 |
# File 'lib/atig/db/transaction.rb', line 40 def debug(s) if respond_to? :log log :debug, s end end |
#init ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/atig/db/transaction.rb', line 10 def init return if @queue debug "transaction thread start" @queue = SizedQueue.new 10 daemon do f,src = @queue.pop debug "transaction is poped at #{src}" if respond_to?(:timeout_interval) && timeout_interval > 0 then begin timeout(timeout_interval){ f.call self } rescue TimeoutError debug "transaction is timeout at #{src}" end else f.call self end debug "transaction is finished at #{src}" end end |
#transaction(&f) ⇒ Object
33 34 35 36 37 38 |
# File 'lib/atig/db/transaction.rb', line 33 def transaction(&f) init debug "transaction is registered" @queue.push [ f, caller.first ] end |