mailbox 0.2.4 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 2
4
- :patch: 4
4
+ :patch: 5
5
5
  :build:
data/lib/synchronized.rb CHANGED
@@ -3,12 +3,14 @@
3
3
  # This module goes hand in hand with +Mailbox+.
4
4
  # It simplifies concurrecncy within your
5
5
  # JRuby applications.
6
+ require 'monitor'
7
+
6
8
  module Synchronized
7
9
 
8
10
  private
9
11
 
10
- def __mutex__
11
- @mutex ||= Mutex.new
12
+ def __synchronizer__
13
+ @synchronizer ||= Monitor.new
12
14
  end
13
15
 
14
16
  def self.included(base)
@@ -27,6 +29,7 @@ module Synchronized
27
29
  def synchronized
28
30
  @synchronized = true
29
31
  end
32
+
30
33
 
31
34
  private
32
35
 
@@ -46,7 +49,7 @@ module Synchronized
46
49
 
47
50
 
48
51
  define_method( method_name, lambda do |*args|
49
- __mutex__.synchronize { self.send(:"__#{method_name}__", *args ) }
52
+ __synchronizer__.synchronize { self.send(:"__#{method_name}__", *args ) }
50
53
  end )
51
54
 
52
55
  @is_adding_synchronized_to_method = false
@@ -62,4 +65,4 @@ module Synchronized
62
65
 
63
66
  end
64
67
 
65
- end
68
+ end
data/mailbox.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{mailbox}
8
- s.version = "0.2.4"
8
+ s.version = "0.2.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Joel Friedman", "Patrick Farley"]
12
- s.date = %q{2010-06-02}
12
+ s.date = %q{2010-09-21}
13
13
  s.description = %q{Mailbox is a JRuby module that simplifies concurrency and is backed by JVM threads.}
14
14
  s.email = %q{asher.friedman@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -85,4 +85,23 @@ class SynchronizedTest < Test::Unit::TestCase
85
85
  assert_equal "thread 2", clazz.values[3], "4th wrong"
86
86
 
87
87
  end
88
+
89
+ def test_support_reentrant_synchronized_access
90
+ klass = Class.new do
91
+ include Mailbox
92
+
93
+ synchronized
94
+ def test_method_one
95
+ test_method_two
96
+ end
97
+
98
+ synchronized
99
+ def test_method_two
100
+ true
101
+ end
102
+ end
103
+
104
+ clazz = klass.new
105
+ assert clazz.test_method_one
106
+ end
88
107
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 4
9
- version: 0.2.4
8
+ - 5
9
+ version: 0.2.5
10
10
  platform: ruby
11
11
  authors:
12
12
  - Joel Friedman
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-06-02 00:00:00 -05:00
18
+ date: 2010-09-21 00:00:00 -05:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency