rdispatch 0.0.1d → 0.0.1e

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rdispatch.rb +7 -6
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2c59c9c62603d6c77df26caa5418aebd2575b3ab
4
- data.tar.gz: c7a915078a015015f916a9b032162899153f611d
3
+ metadata.gz: fe4001710114e7b977901bc8e9f7af3570cc4056
4
+ data.tar.gz: 1d407d63364dc5ffcbbea4ded19e4836d1cf34e9
5
5
  SHA512:
6
- metadata.gz: 1c3b344b151214b912d41a45bf81fff87b7b72d6457b9125aa2a2caf52177ecb2d3d8509a81bd08300f6c75f314303dd1b8d39b59a5b529a0e9462599eac3fe2
7
- data.tar.gz: 26aaf59dc120032641cd4b5d9de3401b0b3251a2f970b35ead50cafb062238f57f8565bc6920aba6b6c235163e38246c55e3692d5d74cd3f32af9e32637f6c07
6
+ metadata.gz: 272e237c26dba840b2f914ff3042466acf23ef9999bd11afd131115c21cfb6d067c285c19771a38a155fdc3da304dc644d50b597ef2f19f31ce59f7789402383
7
+ data.tar.gz: a4850bfb72f12fa715013c36c142b563a63346aadcec3a1bf2ec111630ee662c2c620b018acf5acbfd79ddb90434e82de31a592e58aa5326c3adf03592f9e6d8
data/lib/rdispatch.rb CHANGED
@@ -1,8 +1,7 @@
1
1
  class RDispatch
2
2
 
3
- tasks = []
4
3
  def initialize
5
- tasks = []
4
+ @tasks = []
6
5
  end
7
6
 
8
7
  def create_task(callback, data)
@@ -13,22 +12,24 @@ class RDispatch
13
12
  split_data = data.each_slice((data.size/avail_threads.to_f).round).to_a
14
13
  split_data.each do |data_array|
15
14
  # create tasks, each with 1/n of data, where n is number of cpu cores
16
- tasks << proc { callback.call(data_array) }
15
+ @tasks << proc { callback.call(data_array) }
17
16
  end
18
17
  end
19
18
 
20
19
  def run!
21
20
  # run tasks, each in its own thread
22
21
  threads = []
23
- tasks.each do |t|
22
+ @tasks.each do |t|
23
+ puts "spawning thread"
24
24
  threads << Thread.new do
25
- puts "spawning thread"
26
25
  t.call
27
26
  end
28
27
  end
29
28
  threads.each(&:join)
30
- tasks = []
29
+ @tasks = []
31
30
  end
32
31
 
32
+ private
33
+ @tasks = []
33
34
  end
34
35
  require 'rdispatch/sys'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdispatch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1d
4
+ version: 0.0.1e
5
5
  platform: ruby
6
6
  authors:
7
7
  - Valeriy Antonov