eldritch 1.1.2 → 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +8 -5
- data/README.md +60 -40
- data/Rakefile +1 -0
- data/eldritch.gemspec +9 -6
- data/lib/eldritch/version.rb +1 -1
- data/spec/group_spec.rb +1 -1
- data/spec/thread_spec.rb +3 -3
- metadata +11 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0029674d95d47b443308382c873120b5c7fd507c'
|
4
|
+
data.tar.gz: 8bb6d0df4b1cd1e8607ec109f30ad9eb52611f73
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2bfe6196949f7592dfb8c9e495c005ab31c85e05cdba5bc43b457187a0bf453b56af37209c2ee79c1fbe4984526c971d38a47c283fa053376a4a2e2003b63dd0
|
7
|
+
data.tar.gz: c65441b47ef5fcea16be78f52f5153c51c0e9a54a5a7ac2dad771dfa22034178a8a6b2c8d1cccd570a64efd2949f5a12c3584c8938ad0e0f9db4b8f677a9dfcb
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,26 +1,24 @@
|
|
1
1
|
Eldritch
|
2
2
|
========
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
[![Build Status](http://travis-ci.org/dotboris/eldritch.svg?branch=master)](http://travis-ci.org/dotboris/eldritch)
|
5
|
+
[![Coverage Status](http://coveralls.io/repos/dotboris/eldritch/badge.png)](http://coveralls.io/r/dotboris/eldritch)
|
6
|
+
[![Code Climate](http://codeclimate.com/github/dotboris/eldritch.png)](http://codeclimate.com/github/dotboris/eldritch)
|
7
7
|
|
8
|
-
|
9
|
-
------------
|
8
|
+
_The dark arts of concurrent programming._
|
10
9
|
|
11
|
-
|
12
|
-
|
13
|
-
[![Code Climate](http://codeclimate.com/github/beraboris/eldritch.png)](http://codeclimate.com/github/beraboris/eldritch)
|
10
|
+
A DSL that adds parallel programming constructs to make your life a little
|
11
|
+
easier.
|
14
12
|
|
15
13
|
Usage
|
16
14
|
-----
|
17
15
|
|
18
|
-
1.
|
19
|
-
|
20
|
-
|
16
|
+
1. Install it `gem install eldritch`
|
17
|
+
1. Require it `require 'eldritch'`
|
18
|
+
1. Use it (see features below)
|
21
19
|
|
22
|
-
By default eldritch will inject the DSL into the global scope. If you don't want
|
23
|
-
instead of `eldritch`.
|
20
|
+
By default eldritch will inject the DSL into the global scope. If you don't want
|
21
|
+
this, you can require `eldritch/safe` instead of `eldritch`.
|
24
22
|
|
25
23
|
```ruby
|
26
24
|
require 'eldricth/safe'
|
@@ -33,13 +31,40 @@ class MyClass
|
|
33
31
|
end
|
34
32
|
```
|
35
33
|
|
34
|
+
Development
|
35
|
+
-----------
|
36
|
+
|
37
|
+
### Setup
|
38
|
+
|
39
|
+
```sh
|
40
|
+
bundler install
|
41
|
+
```
|
42
|
+
|
43
|
+
### Running tests
|
44
|
+
|
45
|
+
```sh
|
46
|
+
bundler exec rake
|
47
|
+
```
|
48
|
+
|
49
|
+
### Running examples
|
50
|
+
|
51
|
+
```sh
|
52
|
+
ruby -I lib examples/{your favorite example}.rb
|
53
|
+
```
|
54
|
+
|
55
|
+
### Generate doc
|
56
|
+
|
57
|
+
```sh
|
58
|
+
bundle exec rake doc
|
59
|
+
```
|
60
|
+
|
36
61
|
Features
|
37
62
|
--------
|
38
63
|
|
39
64
|
### async methods
|
40
65
|
|
41
|
-
Async methods run concurrently when called. The caller is returned control right
|
42
|
-
background.
|
66
|
+
Async methods run concurrently when called. The caller is returned control right
|
67
|
+
away and the method runs in the background.
|
43
68
|
|
44
69
|
```ruby
|
45
70
|
require 'eldritch'
|
@@ -63,8 +88,8 @@ end
|
|
63
88
|
async :foo
|
64
89
|
```
|
65
90
|
|
66
|
-
Since ruby 2.1.0, def returns the name of the method defined as a symbol. This
|
67
|
-
syntax.
|
91
|
+
Since ruby 2.1.0, def returns the name of the method defined as a symbol. This
|
92
|
+
allows for the cleaner `async def foo` syntax.
|
68
93
|
|
69
94
|
### async blocks
|
70
95
|
|
@@ -80,7 +105,8 @@ end
|
|
80
105
|
|
81
106
|
### tasks
|
82
107
|
|
83
|
-
Async blocks and async methods both return tasks. These can be used to interact
|
108
|
+
Async blocks and async methods both return tasks. These can be used to interact
|
109
|
+
with the async block/method.
|
84
110
|
|
85
111
|
```ruby
|
86
112
|
require 'eldritch'
|
@@ -95,8 +121,9 @@ res = 2 + task.value # waits for the task to finish
|
|
95
121
|
|
96
122
|
### together blocks
|
97
123
|
|
98
|
-
Together blocks are used to control all async blocks and methods within them as
|
99
|
-
wait for all their async calls to be
|
124
|
+
Together blocks are used to control all async blocks and methods within them as
|
125
|
+
a group. Before exiting, together blocks wait for all their async calls to be
|
126
|
+
done before returning.
|
100
127
|
|
101
128
|
```ruby
|
102
129
|
require 'eldritch'
|
@@ -111,8 +138,9 @@ end
|
|
111
138
|
# all 1000 tasks are done
|
112
139
|
```
|
113
140
|
|
114
|
-
These blocks can also take an argument. This argument is a group that can be
|
115
|
-
block. See the documentation for
|
141
|
+
These blocks can also take an argument. This argument is a group that can be
|
142
|
+
used to control the async calls in the block. See the documentation for
|
143
|
+
Eldritch::Group for more information.
|
116
144
|
|
117
145
|
```ruby
|
118
146
|
require 'eldritch'
|
@@ -130,24 +158,16 @@ end
|
|
130
158
|
A note on GIL
|
131
159
|
-------------
|
132
160
|
|
133
|
-
MRI has this nasty little feature called a _GIL_ or _Global Interpreter Lock_.
|
134
|
-
thread can run at a time. Let's say that you
|
135
|
-
|
161
|
+
MRI has this nasty little feature called a _GIL_ or _Global Interpreter Lock_.
|
162
|
+
This lock makes it so that only one thread can run at a time. Let's say that you
|
163
|
+
have 4 cores, running threaded code on MRI will only make use of 1 core.
|
164
|
+
Sometimes, you might not gain a speed boost if you make code parallel. This
|
165
|
+
could the case even if theory says otherwise.
|
136
166
|
|
137
|
-
Not all ruby implementations use a _GIL_. For example, jRuby does not use a
|
167
|
+
Not all ruby implementations use a _GIL_. For example, jRuby does not use a
|
168
|
+
_GIL_.
|
138
169
|
|
139
|
-
If your ruby implementation has a _GIL_, you will probably see a speed boost if
|
140
|
-
that's blocking. In that case running on
|
170
|
+
If your ruby implementation has a _GIL_, you will probably see a speed boost if
|
171
|
+
your code does a lot of IO or anything that's blocking. In that case running on
|
172
|
+
a single core is not that much of a hindrance, because most of the threads will
|
141
173
|
be blocked and your code should run more often.
|
142
|
-
|
143
|
-
Running examples
|
144
|
-
----------------
|
145
|
-
|
146
|
-
If you installed eldritch with gem, you can just run the examples directly. If you are running them against a clone of
|
147
|
-
this repository you need to add `lib/` to the include path.
|
148
|
-
|
149
|
-
$ ruby -Ilib examples/the_example.rb
|
150
|
-
|
151
|
-
Be aware that if you are running ruby < 2.1.0, some the examples may not work. All the examples that define async
|
152
|
-
methods with `async def something; end` will not work. This is because, since ruby 2.1.0, def returns the name of the
|
153
|
-
method defined as a symbol.
|
data/Rakefile
CHANGED
data/eldritch.gemspec
CHANGED
@@ -7,10 +7,13 @@ Gem::Specification.new do |spec|
|
|
7
7
|
spec.name = 'eldritch'
|
8
8
|
spec.version = Eldritch::VERSION
|
9
9
|
spec.authors = ['Boris Bera', 'François Genois']
|
10
|
-
spec.email = %w(
|
11
|
-
spec.summary =
|
12
|
-
|
13
|
-
spec.
|
10
|
+
spec.email = %w(bera.boris@gmail.com frankgenerated@gmail.com)
|
11
|
+
spec.summary = 'DSL that adds concurrent programming concepts to ' \
|
12
|
+
'make your life easier.'
|
13
|
+
spec.description = 'Adds support for async methods and async blocks. ' \
|
14
|
+
'Adds a together block that allows async ' \
|
15
|
+
'methods/blocks to be controlled as a group.'
|
16
|
+
spec.homepage = 'https://github.com/dotboris/eldritch'
|
14
17
|
spec.license = 'MIT'
|
15
18
|
|
16
19
|
spec.files = `git ls-files -z`.split("\x0")
|
@@ -21,7 +24,7 @@ Gem::Specification.new do |spec|
|
|
21
24
|
spec.add_dependency 'reentrant_mutex', '~> 1.1.0'
|
22
25
|
|
23
26
|
spec.add_development_dependency 'bundler', '~> 1.5'
|
24
|
-
spec.add_development_dependency 'rake'
|
27
|
+
spec.add_development_dependency 'rake', '~> 11.0'
|
25
28
|
spec.add_development_dependency 'rspec', '~> 2.14'
|
26
|
-
spec.add_development_dependency 'yard', '~> 0.
|
29
|
+
spec.add_development_dependency 'yard', '~> 0.9.11'
|
27
30
|
end
|
data/lib/eldritch/version.rb
CHANGED
data/spec/group_spec.rb
CHANGED
data/spec/thread_spec.rb
CHANGED
@@ -29,17 +29,17 @@ describe Thread do
|
|
29
29
|
describe '#in_group?' do
|
30
30
|
it 'should be false when group is nil' do
|
31
31
|
thread.eldritch_group = nil
|
32
|
-
expect(thread.in_eldritch_group?).to
|
32
|
+
expect(thread.in_eldritch_group?).to be_falsey
|
33
33
|
end
|
34
34
|
|
35
35
|
it 'should be false when group is a NilGroup' do
|
36
36
|
thread.eldritch_group = Eldritch::NilGroup.new
|
37
|
-
expect(thread.in_eldritch_group?).to
|
37
|
+
expect(thread.in_eldritch_group?).to be_falsey
|
38
38
|
end
|
39
39
|
|
40
40
|
it 'should be true when group is set' do
|
41
41
|
thread.eldritch_group = 2
|
42
|
-
expect(thread.in_eldritch_group?).to
|
42
|
+
expect(thread.in_eldritch_group?).to be_truthy
|
43
43
|
end
|
44
44
|
end
|
45
45
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eldritch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Boris Bera
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2017-12-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: reentrant_mutex
|
@@ -43,16 +43,16 @@ dependencies:
|
|
43
43
|
name: rake
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- - "
|
46
|
+
- - "~>"
|
47
47
|
- !ruby/object:Gem::Version
|
48
|
-
version: '0'
|
48
|
+
version: '11.0'
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- - "
|
53
|
+
- - "~>"
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: '0'
|
55
|
+
version: '11.0'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: rspec
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
@@ -73,18 +73,18 @@ dependencies:
|
|
73
73
|
requirements:
|
74
74
|
- - "~>"
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version: 0.
|
76
|
+
version: 0.9.11
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
81
|
- - "~>"
|
82
82
|
- !ruby/object:Gem::Version
|
83
|
-
version: 0.
|
83
|
+
version: 0.9.11
|
84
84
|
description: Adds support for async methods and async blocks. Adds a together block
|
85
85
|
that allows async methods/blocks to be controlled as a group.
|
86
86
|
email:
|
87
|
-
-
|
87
|
+
- bera.boris@gmail.com
|
88
88
|
- frankgenerated@gmail.com
|
89
89
|
executables: []
|
90
90
|
extensions: []
|
@@ -120,7 +120,7 @@ files:
|
|
120
120
|
- spec/spec_helper.rb
|
121
121
|
- spec/task_spec.rb
|
122
122
|
- spec/thread_spec.rb
|
123
|
-
homepage: https://github.com/
|
123
|
+
homepage: https://github.com/dotboris/eldritch
|
124
124
|
licenses:
|
125
125
|
- MIT
|
126
126
|
metadata: {}
|
@@ -140,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
140
140
|
version: '0'
|
141
141
|
requirements: []
|
142
142
|
rubyforge_project:
|
143
|
-
rubygems_version: 2.
|
143
|
+
rubygems_version: 2.6.14
|
144
144
|
signing_key:
|
145
145
|
specification_version: 4
|
146
146
|
summary: DSL that adds concurrent programming concepts to make your life easier.
|
@@ -151,4 +151,3 @@ test_files:
|
|
151
151
|
- spec/spec_helper.rb
|
152
152
|
- spec/task_spec.rb
|
153
153
|
- spec/thread_spec.rb
|
154
|
-
has_rdoc:
|