Class: Amalgalite::BusyTimeout
- Inherits:
-
BusyHandler
- Object
- BusyHandler
- Amalgalite::BusyTimeout
- Defined in:
- lib/amalgalite/busy_timeout.rb
Overview
A busy time out class for use in Database#define_busy_handler
Instance Attribute Summary collapse
-
#call_count ⇒ Object
readonly
Returns the value of attribute call_count.
Instance Method Summary collapse
-
#call(call_count) ⇒ Object
return
false
if callcount is > count otherwise sleep for duration milliseconds and then returntrue
. -
#initialize(count = 20, duration = 50) ⇒ BusyTimeout
constructor
intialize by setting count and duration ( in milliseconds ).
Methods inherited from BusyHandler
Constructor Details
#initialize(count = 20, duration = 50) ⇒ BusyTimeout
intialize by setting count and duration ( in milliseconds ).
30 31 32 33 34 |
# File 'lib/amalgalite/busy_timeout.rb', line 30 def initialize( count = 20 , duration = 50 ) @count = count @duration = duration.to_f / 1_000 @call_count = 0 end |
Instance Attribute Details
#call_count ⇒ Object (readonly)
Returns the value of attribute call_count.
26 27 28 |
# File 'lib/amalgalite/busy_timeout.rb', line 26 def call_count @call_count end |
Instance Method Details
#call(call_count) ⇒ Object
return false
if callcount is > count otherwise sleep for duration milliseconds and then return true
40 41 42 43 44 45 |
# File 'lib/amalgalite/busy_timeout.rb', line 40 def call( call_count ) @call_count = call_count return false if ( call_count > @count ) sleep @duration return true end |