multithreads_each 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +27 -7
- data/Rakefile +6 -0
- data/lib/multithreads_each.rb +2 -9
- data/lib/multithreads_each/array_method.rb +12 -0
- data/lib/multithreads_each/version.rb +1 -1
- data/multithreads_each.gemspec +1 -0
- data/spec/mulithreads_each_spec.rb +13 -0
- data/spec/spec_helper.rb +5 -0
- metadata +22 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c567f022534092bae5c9233d69d88ac45b9fe0b6
|
4
|
+
data.tar.gz: 755cbe057f425e5e1e61a9ece90a42ad6ea01201
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 501010ea648c2828d91e6218b2ace0cd56b4e7bdd2212dd585fab7456bcf0e3eff19e261d4a80735604169bac7313527f62f8a862fd299bf819f3d43d739c895
|
7
|
+
data.tar.gz: b348781323e09b1351ea21236b5f65f04c070959f234d262ca0aa3a75a198adbfdfa9421c9705135eb8e8cc00ab343effec628ca2d850838d84a267e1aae609f
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# MultithreadsEach
|
2
2
|
|
3
|
-
|
3
|
+
Simple syntactic sugar for arrays that performs the same actions as the method each, but creates a new thread for every call
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -8,17 +8,37 @@ Add this line to your application's Gemfile:
|
|
8
8
|
|
9
9
|
gem 'multithreads_each'
|
10
10
|
|
11
|
-
And then execute:
|
12
|
-
|
13
|
-
$ bundle
|
14
|
-
|
15
11
|
Or install it yourself as:
|
16
12
|
|
17
13
|
$ gem install multithreads_each
|
18
14
|
|
19
15
|
## Usage
|
20
|
-
|
21
|
-
|
16
|
+
Using almost the same as the method each:
|
17
|
+
|
18
|
+
cities = %w(Moscow Berlin London Praga Kiev)
|
19
|
+
|
20
|
+
cities.multithreads_each do |city|
|
21
|
+
# Actions
|
22
|
+
end
|
23
|
+
|
24
|
+
For each element will be created a new thread:
|
25
|
+
|
26
|
+
def slow_function(foo)
|
27
|
+
sleep 5
|
28
|
+
puts foo
|
29
|
+
end
|
30
|
+
|
31
|
+
array = %w(1 2 3 4 5)
|
32
|
+
|
33
|
+
# Will be completed after ~25 seconds
|
34
|
+
array.each do |elem|
|
35
|
+
slow_function(elem)
|
36
|
+
end
|
37
|
+
|
38
|
+
# Will be completed after ~5 seconds
|
39
|
+
array.multithreads_each do |elem|
|
40
|
+
slow_function(elem)
|
41
|
+
end
|
22
42
|
|
23
43
|
## Contributing
|
24
44
|
|
data/Rakefile
CHANGED
data/lib/multithreads_each.rb
CHANGED
@@ -1,13 +1,6 @@
|
|
1
1
|
require "multithreads_each/version"
|
2
|
+
require "multithreads_each/array_method"
|
2
3
|
|
3
|
-
|
4
|
-
def multithreads_each(options={})
|
5
|
-
threads = []
|
4
|
+
module MultithreadsEach
|
6
5
|
|
7
|
-
self.each do |n|
|
8
|
-
threads << Thread.new { yield n }
|
9
|
-
end
|
10
|
-
|
11
|
-
threads.each { |thread| thread.join }
|
12
|
-
end
|
13
6
|
end
|
data/multithreads_each.gemspec
CHANGED
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: multithreads_each
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TakteS
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-04-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
description: Simple syntactic sugar for arrays that performs the same actions as the
|
42
56
|
method each, but creates a new thread for every call
|
43
57
|
email:
|
@@ -52,8 +66,11 @@ files:
|
|
52
66
|
- README.md
|
53
67
|
- Rakefile
|
54
68
|
- lib/multithreads_each.rb
|
69
|
+
- lib/multithreads_each/array_method.rb
|
55
70
|
- lib/multithreads_each/version.rb
|
56
71
|
- multithreads_each.gemspec
|
72
|
+
- spec/mulithreads_each_spec.rb
|
73
|
+
- spec/spec_helper.rb
|
57
74
|
homepage: https://github.com/TakteS/multithreads_each
|
58
75
|
licenses:
|
59
76
|
- MIT
|
@@ -78,4 +95,6 @@ rubygems_version: 2.1.11
|
|
78
95
|
signing_key:
|
79
96
|
specification_version: 4
|
80
97
|
summary: Multithreads each for arrays
|
81
|
-
test_files:
|
98
|
+
test_files:
|
99
|
+
- spec/mulithreads_each_spec.rb
|
100
|
+
- spec/spec_helper.rb
|