Top Level Namespace
Defined Under Namespace
Modules: ActiveRecord, Codefly
Instance Method Summary
collapse
Instance Method Details
#fly(id) ⇒ Object
28
29
30
31
32
33
34
35
36
|
# File 'lib/codefly.rb', line 28
def fly(id)
return unless block_given?
raise 'ID already in use' if @fly_thrs.has_key? id
@fly_thrs[id] = Thread.new do
Thread.current[:connection] = :new
yield
ActiveRecord::Base.connection_pool.checkin(Thread.current[:connection]) if Thread.current[:connection] != :new
end
end
|
#wait_fly(*ids) ⇒ Object
38
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/codefly.rb', line 38
def wait_fly(*ids)
ids.each do |id|
if @fly_thrs[id].present?
begin
@fly_thrs[id].value ensure
@fly_thrs.delete(id) end
end
end
end
|