thread 0.1.1 → 0.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: acd751cb226565073139b06c1ca6594027b8b62e
4
- data.tar.gz: 2a7a2de127998b53448104cd363349baba61506b
3
+ metadata.gz: 5f8b2b8b2de2d12fa2255966aea69b62e0be09e2
4
+ data.tar.gz: 5b8c58cdca06730258e4481ea6d5ff8cb2c62d58
5
5
  SHA512:
6
- metadata.gz: 90ba38b474c1c8571a48f651d7c78543dcb71b10ab5dfa0b44a312962b2d7a1eee512299f97d20ad1dc8673ea30eed31a5872d01e3c0724b1a487e2fe6218379
7
- data.tar.gz: 8c76e2f2dd336d9c9a448c99cf6ea2743727ee98f79018a0f7d30cce6fa3a9896b1c778f9711788e83c291c843ea4bab58ec6f4f873d72c41a25ada19073e7b9
6
+ metadata.gz: 362ca6bf0a6b5e7fe907cbb1d060facba2bbe7ebbb8e93604b220cba505d9ffbe3e8216a058d051133c5314332e9f00e2933452b302ea264e65b69f6cfa69a8e
7
+ data.tar.gz: 99296e2a1bff5431616265fc921cf2d886b17e4ee0ba4dca4dffebd1b81877921818133fe4e50a82559352c3555c065d6098e4024bda7f3a55c73ddf95650a76
@@ -16,6 +16,7 @@ require 'thread'
16
16
  # You really shouldn't use this, but in some cases it makes your life easier.
17
17
  class RecursiveMutex < Mutex
18
18
  def initialize
19
+ @threads_lock = Mutex.new
19
20
  @threads = Hash.new { |h, k| h[k] = 0 }
20
21
 
21
22
  super
@@ -23,19 +24,13 @@ class RecursiveMutex < Mutex
23
24
 
24
25
  # Lock the mutex.
25
26
  def lock
26
- @thread[Thread.current] += 1
27
-
28
- if @thread[Thread.current] == 1
29
- super
30
- end
27
+ super if @threads_lock.synchronize{ (@threads[Thread.current] += 1) == 1 }
31
28
  end
32
29
 
33
30
  # Unlock the mutex.
34
31
  def unlock
35
- @thread[Thread.current] -= 1
36
-
37
- if @thread[Thread.current] == 0
38
- @thread.delete(Thread.current)
32
+ if @threads_lock.synchronize{ (@threads[Thread.current] -= 1) == 0 }
33
+ @threads.delete(Thread.current)
39
34
 
40
35
  super
41
36
  end
data/thread.gemspec CHANGED
@@ -1,12 +1,13 @@
1
1
  Gem::Specification.new {|s|
2
2
  s.name = 'thread'
3
- s.version = '0.1.1'
3
+ s.version = '0.1.2'
4
4
  s.author = 'meh.'
5
5
  s.email = 'meh@schizofreni.co'
6
6
  s.homepage = 'http://github.com/meh/ruby-thread'
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.summary = 'Various extensions to the base thread library.'
9
9
  s.description = 'Includes a thread pool, message passing capabilities, a recursive mutex, promise, future and delay.'
10
+ s.license = 'WTFPL'
10
11
 
11
12
  s.files = `git ls-files`.split("\n")
12
13
  s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
metadata CHANGED
@@ -1,41 +1,41 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thread
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - meh.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-09 00:00:00.000000000 Z
11
+ date: 2013-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  description: Includes a thread pool, message passing capabilities, a recursive mutex,
@@ -45,7 +45,7 @@ executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
- - .travis.yml
48
+ - ".travis.yml"
49
49
  - README.md
50
50
  - Rakefile
51
51
  - lib/thread/channel.rb
@@ -65,7 +65,8 @@ files:
65
65
  - tests/promise_spec.rb
66
66
  - thread.gemspec
67
67
  homepage: http://github.com/meh/ruby-thread
68
- licenses: []
68
+ licenses:
69
+ - WTFPL
69
70
  metadata: {}
70
71
  post_install_message:
71
72
  rdoc_options: []
@@ -73,17 +74,17 @@ require_paths:
73
74
  - lib
74
75
  required_ruby_version: !ruby/object:Gem::Requirement
75
76
  requirements:
76
- - - '>='
77
+ - - ">="
77
78
  - !ruby/object:Gem::Version
78
79
  version: '0'
79
80
  required_rubygems_version: !ruby/object:Gem::Requirement
80
81
  requirements:
81
- - - '>='
82
+ - - ">="
82
83
  - !ruby/object:Gem::Version
83
84
  version: '0'
84
85
  requirements: []
85
86
  rubyforge_project:
86
- rubygems_version: 2.0.3
87
+ rubygems_version: 2.1.5
87
88
  signing_key:
88
89
  specification_version: 4
89
90
  summary: Various extensions to the base thread library.