README.md in concurrent_worker-0.1.3 vs README.md in concurrent_worker-0.2.0
- old
+ new
@@ -1,8 +1,8 @@
# ConcurrentWorker
-Concurrent worker in thread/process with preparation structure.
+Concurrent worker in thread/process with preparation mechanism.
## Installation
Add this line to your application's Gemfile.
@@ -52,11 +52,11 @@
nil
end
# define base block for some preparation of work block.
logger.set_block(:base_block) do
- open( "log.txt" , "w" ) do |file|
+ open("log.txt", "w") do |file|
@file = file
# 'yield_loop_block' must be called in base block.
# work block will be called in this call.
yield_loop_block
end
@@ -70,15 +70,15 @@
You can exec work block in some process concurrently.
```ruby
#define a pool of 8 workers , executed in other process.
wp = ConcurrentWorker::WorkerPool.new(type: :process, pool_max: 8) do |n|
- [n , n.times.inject(:+)]
+ [n, n.times.inject(:+)]
end
# you can receive the result of work block with callback block.
wp.add_callback do |n, result|
- logger.log( "n=%d,result=%d", n, result)
+ logger.req("n=%d,result=%d", n, result)
end
(10000000..10000200).each do |n|
wp.req(n)
end