Sha256: c8f71a371053580fe0c64e649ba36845f5e8bd7cd9a8092b8f0001eea0e9183a
Contents?: true
Size: 1.17 KB
Versions: 83
Compression:
Stored size: 1.17 KB
Contents
module Amalgalite ## # A base class for use in creating your own busy handler classes # class BusyHandler def to_proc self end # the arity of the call method def arity() 1 ; end ## # Override this method, returning +false+ if the SQLite should return # SQLITE_BUSY for all parties involved in the lock, and anything else if the # lock attempt should be tried again. def call( count ) raise NotImplementedError, "The busy handler call(N) method must be implemented" end end ## # A busy time out class for use in Database#define_busy_handler # class BusyTimeout < BusyHandler attr_reader :call_count ## # intialize by setting _count_ and _duration_ ( in milliseconds ). # def initialize( count = 20 , duration = 50 ) @count = count @duration = duration.to_f / 1_000 @call_count = 0 end ## # return +false+ if _callcount_ is > _count_ otherwise sleep for _duration_ # milliseconds and then return +true+ # def call( call_count ) @call_count = call_count return false if ( call_count > @count ) sleep @duration return true end end end
Version data entries
83 entries across 83 versions & 2 rubygems
Version | Path |
---|---|
amalgalite-0.8.0 | lib/amalgalite/busy_timeout.rb |
amalgalite-0.8.0-x86-mswin32-60 | lib/amalgalite/busy_timeout.rb |
amalgalite-0.9.0 | lib/amalgalite/busy_timeout.rb |