| Class | SingleThreadedPool |
| In: |
lib/assistance/connection_pool.rb
|
| Parent: | Object |
A SingleThreadedPool acts as a replacement for a ConnectionPool for use in single-threaded applications. ConnectionPool imposes a substantial performance penalty, so SingleThreadedPool is used to gain some speed.
| conn | [R] | |
| connection_proc | [W] |
Initializes the instance with the supplied block as the connection_proc.
# File lib/assistance/connection_pool.rb, line 130
130: def initialize(&block)
131: @connection_proc = block
132: end
Yields the connection to the supplied block. This method simulates the ConnectionPool#hold API.
# File lib/assistance/connection_pool.rb, line 136
136: def hold
137: @conn ||= @connection_proc.call
138: yield @conn
139: rescue Exception => e
140: # if the error is not a StandardError it is converted into RuntimeError.
141: raise e.is_a?(StandardError) ? e : e.message
142: end