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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b580cd9181ade4f4a2a6976341a88b3059ad5670
4
- data.tar.gz: a9947d828dfd477bccbed94f5713c1620de2063e
3
+ metadata.gz: 7f11d72de9ceca37537053989ae07e2b4e71fae6
4
+ data.tar.gz: c0dc96920ae2eda7605643148deee8a32c5c41a2
5
5
  SHA512:
6
- metadata.gz: f336489e6ef818dc9dc92a02b90d94c9b2aa9fb389286f0b80ecaa75ab800c183754bfa43eb2237e2e4c30c229d04e8af354f5dd1a228f61a74a1498847ded4a
7
- data.tar.gz: 370a2d8c641f8fda77846fec17ce8e6c7dc0dcc0825952c900e0bbb625dd71e999b64af70ae86453399d8d5936832c96de699cedfe7da992e8f59b61bdc3bb05
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 controlled right away and the method runs in the
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 { puts password }
30
+ group.synchronize do
31
+ puts password
31
32
 
32
- # stop all the other threads
33
- group.interrupt
34
- break
33
+ # stop the other tasks
34
+ group.interrupt
35
+ break
36
+ end
35
37
  end
36
38
  end
37
39
  end
@@ -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 = Mutex.new
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
- # copy accept for the task.start condition
23
- accept = @accept
24
- @tasks << task if accept
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
@@ -1,3 +1,3 @@
1
1
  module Eldritch
2
- VERSION = '1.1.1'
2
+ VERSION = '1.1.2'
3
3
  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.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-04-28 00:00:00.000000000 Z
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