eldritch 1.1.1 → 1.1.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 +1 -1
- data/eldritch.gemspec +2 -0
- data/examples/password_cracker.rb +6 -4
- data/lib/eldritch/group.rb +6 -8
- data/lib/eldritch/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f11d72de9ceca37537053989ae07e2b4e71fae6
|
4
|
+
data.tar.gz: c0dc96920ae2eda7605643148deee8a32c5c41a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bdb3db5817c75dd6e655c6bf0dc758f9b2882beefdf831c5f42fbb3b36257706cc61052cbbd7a560dad4127f9648a3ab642df07abdf3e55ad4eedbe9dc79724e
|
7
|
+
data.tar.gz: d3ea8f9e3c1d4c20e5e2467979e460d3d067a02d6db37bc701a9a709bd6b148717829caf4d5b7a13b1854857452712df653dc0f6e907c425c18a5c4cc76279ef
|
data/README.md
CHANGED
@@ -38,7 +38,7 @@ Features
|
|
38
38
|
|
39
39
|
### async methods
|
40
40
|
|
41
|
-
Async methods run concurrently when called. The caller is returned
|
41
|
+
Async methods run concurrently when called. The caller is returned control right away and the method runs in the
|
42
42
|
background.
|
43
43
|
|
44
44
|
```ruby
|
data/eldritch.gemspec
CHANGED
@@ -18,6 +18,8 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ['lib']
|
20
20
|
|
21
|
+
spec.add_dependency 'reentrant_mutex', '~> 1.1.0'
|
22
|
+
|
21
23
|
spec.add_development_dependency 'bundler', '~> 1.5'
|
22
24
|
spec.add_development_dependency 'rake'
|
23
25
|
spec.add_development_dependency 'rspec', '~> 2.14'
|
@@ -27,11 +27,13 @@ together do |group|
|
|
27
27
|
async do
|
28
28
|
slice.each do |password|
|
29
29
|
if hash == Digest::MD5.hexdigest(password)
|
30
|
-
group.synchronize
|
30
|
+
group.synchronize do
|
31
|
+
puts password
|
31
32
|
|
32
|
-
|
33
|
-
|
34
|
-
|
33
|
+
# stop the other tasks
|
34
|
+
group.interrupt
|
35
|
+
break
|
36
|
+
end
|
35
37
|
end
|
36
38
|
end
|
37
39
|
end
|
data/lib/eldritch/group.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'thread'
|
2
|
+
require 'reentrant_mutex'
|
2
3
|
|
3
4
|
module Eldritch
|
4
5
|
# Represents a group of {Task tasks} or {DSL#async async calls/block}.
|
@@ -6,7 +7,7 @@ module Eldritch
|
|
6
7
|
class Group
|
7
8
|
def initialize
|
8
9
|
@tasks = []
|
9
|
-
@mutex =
|
10
|
+
@mutex = ReentrantMutex.new
|
10
11
|
@accept = true
|
11
12
|
end
|
12
13
|
|
@@ -16,15 +17,12 @@ module Eldritch
|
|
16
17
|
end
|
17
18
|
|
18
19
|
def <<(task)
|
19
|
-
accept = nil
|
20
|
-
|
21
20
|
@mutex.synchronize do
|
22
|
-
|
23
|
-
|
24
|
-
|
21
|
+
if @accept
|
22
|
+
@tasks << task
|
23
|
+
task.start
|
24
|
+
end
|
25
25
|
end
|
26
|
-
|
27
|
-
task.start if accept
|
28
26
|
end
|
29
27
|
|
30
28
|
# Yields the block in mutual exclusion with all the async calls/tasks
|
data/lib/eldritch/version.rb
CHANGED
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.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Boris Bera
|
@@ -9,8 +9,22 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-05-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: reentrant_mutex
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: 1.1.0
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: 1.1.0
|
14
28
|
- !ruby/object:Gem::Dependency
|
15
29
|
name: bundler
|
16
30
|
requirement: !ruby/object:Gem::Requirement
|