Module: Tresse
- Defined in:
- lib/tresse.rb
Defined Under Namespace
Constant Summary collapse
- VERSION =
'1.1.3'
Class Method Summary collapse
- .call_block(block, args) ⇒ Object
- .enqueue(batch) ⇒ Object
- .init ⇒ Object
- .max_work_thread_count ⇒ Object
- .max_work_thread_count=(i) ⇒ Object
- .on_error(&block) ⇒ Object
Class Method Details
.call_block(block, args) ⇒ Object
86 87 88 89 |
# File 'lib/tresse.rb', line 86 def self.call_block(block, args) block.call(*args[0, block.arity.abs]) end |
.enqueue(batch) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/tresse.rb', line 26 def enqueue(batch) @work_queue << batch batch.group end |
.init ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/tresse.rb', line 11 def init @work_queue = Queue.new @work_threads = 8.times.collect { |i| make_work_thread } @on_error = lambda do |where, err| puts "-" * 80 p where p err puts err.backtrace puts "-" * 80 end end |
.max_work_thread_count ⇒ Object
38 39 40 41 |
# File 'lib/tresse.rb', line 38 def max_work_thread_count @work_threads.size end |
.max_work_thread_count=(i) ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'lib/tresse.rb', line 43 def max_work_thread_count=(i) i0 = @work_threads.size @work_threads << make_work_thread while @work_threads.size < i @work_threads.pop while @work_threads.size > i i end |
.on_error(&block) ⇒ Object
33 34 35 36 |
# File 'lib/tresse.rb', line 33 def on_error(&block) @on_error = block end |