lib/sequel/extensions/async_thread_pool.rb in sequel-5.62.0 vs lib/sequel/extensions/async_thread_pool.rb in sequel-5.63.0

- old
+ new

@@ -3,43 +3,43 @@ # The async_thread_pool extension adds support for running database # queries in a separate threads using a thread pool. With the following # code # # DB.extension :async_thread_pool -# foos = DB[:foos].async.where{name: 'A'..'M'}.all +# foos = DB[:foos].async.where(name: 'A'..'M').all # bar_names = DB[:bar].async.select_order_map(:name) # baz_1 = DB[:bazes].async.first(id: 1) # # All 3 queries will be run in separate threads. +foos+, +bar_names+ # and +baz_1+ will be proxy objects. Calling a method on the proxy # object will wait for the query to be run, and will return the result # of calling that method on the result of the query method. For example, # if you run: # -# foos = DB[:foos].async.where{name: 'A'..'M'}.all +# foos = DB[:foos].async.where(name: 'A'..'M').all # bar_names = DB[:bars].async.select_order_map(:name) # baz_1 = DB[:bazes].async.first(id: 1) # sleep(1) # foos.size # bar_names.first # baz_1.name # # These three queries will generally be run concurrently in separate # threads. If you instead run: # -# DB[:foos].async.where{name: 'A'..'M'}.all.size +# DB[:foos].async.where(name: 'A'..'M').all.size # DB[:bars].async.select_order_map(:name).first # DB[:bazes].async.first(id: 1).name # # Then will run each query sequentially, since you need the result of # one query before running the next query. The queries will still be # run in separate threads (by default). # # What is run in the separate thread is the entire method call that # returns results. So with the original example: # -# foos = DB[:foos].async.where{name: 'A'..'M'}.all +# foos = DB[:foos].async.where(name: 'A'..'M').all # bar_names = DB[:bars].async.select_order_map(:name) # baz_1 = DB[:bazes].async.first(id: 1) # # The +all+, <tt>select_order_map(:name)</tt>, and <tt>first(id: 1)</tt> # calls are run in separate threads. If a block is passed to a method @@ -154,10 +154,10 @@ # such as when the async thread pool is busy and the results of a query # are needed right away, it can improve performance to allow preemption, # so that the query will run in the current thread instead of waiting # for an async thread to become available. With the following code: # -# foos = DB[:foos].async.where{name: 'A'..'M'}.all +# foos = DB[:foos].async.where(name: 'A'..'M').all # bar_names = DB[:bar].async.select_order_map(:name) # if foos.length > 4 # baz_1 = DB[:bazes].async.first(id: 1) # end #