rubysl-mutex_m 1.0.0 → 2.0.0

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: 6145f23fe011debee488b2ac0de35f7ce5e6dafc
4
- data.tar.gz: 44b34c816144b234351ec4b4adeb3bde6c258318
3
+ metadata.gz: e62e79371da28c8eeaf1c32a6b0d0c31adac9a8d
4
+ data.tar.gz: 9cadf9530abe49552f379e92520d6eb5b3d81c78
5
5
  SHA512:
6
- metadata.gz: ae23dc5a70e114d7537750c01f68a70e90388a4cfa6549b6a7399a001e1c54f5d96c9537d71b7b3162d64aa314eee51094b92e7e8d7e5ce939d080c5fb3ceb72
7
- data.tar.gz: 9cba2c7635215b5d40b96d3e4e8c8dfef3f98cbaa34c559f5ed732c3e90fbf0d2e68f2d5f58c9bd1b618d1b7cc4f6b489c09eababd000aee88c3fbd8a255d0b8
6
+ metadata.gz: e582d162a426f40077699371f3772fd763c22ff360ff0e80b04166bc0df62fcdb61f85ecf6f7f543bb2ca52b4f2efda071e4cdc2a6ca0ffd411c4db90542898c
7
+ data.tar.gz: d1b086d3647c7ead586dd0dcdfba13e1144caca6cc265b1589ed23be6b2a1372c5389f0b3baf236e313bd604d3ce174001a6beda4a9d5bbdf848ea08b4e80b0e
@@ -1,8 +1,7 @@
1
1
  language: ruby
2
- before_install:
3
- - gem update --system
4
- - gem --version
5
- - gem install rubysl-bundler
6
- script: bundle exec mspec spec
2
+ env:
3
+ - RUBYLIB=lib
4
+ script: bundle exec mspec
7
5
  rvm:
8
- - rbx-nightly-18mode
6
+ - 1.9.3
7
+ - rbx-nightly-19mode
@@ -1,38 +1,43 @@
1
- #--
2
- # mutex_m.rb -
3
- # $Release Version: 3.0$
4
- # $Revision$
5
- # $Date$
1
+ #
2
+ # mutex_m.rb -
3
+ # $Release Version: 3.0$
4
+ # $Revision: 1.7 $
6
5
  # Original from mutex.rb
7
- # by Keiju ISHITSUKA(keiju@ishitsuka.com)
6
+ # by Keiju ISHITSUKA(keiju@ishitsuka.com)
8
7
  # modified by matz
9
8
  # patched by akira yamada
10
- # gutted by MenTaLguY
11
- #++
12
9
  #
13
- # == Usage
10
+ # --
11
+
12
+
13
+ require 'thread'
14
+
15
+ # = mutex_m.rb
16
+ #
17
+ # When 'mutex_m' is required, any object that extends or includes Mutex_m will
18
+ # be treated like a Mutex.
14
19
  #
15
- # Extend an object and use it like a Mutex object:
20
+ # Start by requiring the standard library Mutex_m:
16
21
  #
17
22
  # require "mutex_m.rb"
23
+ #
24
+ # From here you can extend an object with Mutex instance methods:
25
+ #
18
26
  # obj = Object.new
19
27
  # obj.extend Mutex_m
20
- # # ...
21
28
  #
22
- # Or, include Mutex_m in a class to have its instances behave like a Mutex
23
- # object:
29
+ # Or mixin Mutex_m into your module to your class inherit Mutex instance
30
+ # methods.
24
31
  #
25
32
  # class Foo
26
33
  # include Mutex_m
27
34
  # # ...
28
35
  # end
29
- #
30
36
  # obj = Foo.new
31
-
32
- require 'thread'
33
-
37
+ # # this obj can be handled like Mutex
38
+ #
34
39
  module Mutex_m
35
- def Mutex_m.define_aliases(cl)
40
+ def Mutex_m.define_aliases(cl) # :nodoc:
36
41
  cl.module_eval %q{
37
42
  alias locked? mu_locked?
38
43
  alias lock mu_lock
@@ -40,59 +45,66 @@ module Mutex_m
40
45
  alias try_lock mu_try_lock
41
46
  alias synchronize mu_synchronize
42
47
  }
43
- end
48
+ end
44
49
 
45
- def Mutex_m.append_features(cl)
50
+ def Mutex_m.append_features(cl) # :nodoc:
46
51
  super
47
52
  define_aliases(cl) unless cl.instance_of?(Module)
48
53
  end
49
-
50
- def Mutex_m.extend_object(obj)
54
+
55
+ def Mutex_m.extend_object(obj) # :nodoc:
51
56
  super
52
57
  obj.mu_extended
53
58
  end
54
59
 
55
- def mu_extended
60
+ def mu_extended # :nodoc:
56
61
  unless (defined? locked? and
57
- defined? lock and
58
- defined? unlock and
59
- defined? try_lock and
60
- defined? synchronize)
61
- Mutex_m.define_aliases(class<<self;self;end)
62
+ defined? lock and
63
+ defined? unlock and
64
+ defined? try_lock and
65
+ defined? synchronize)
66
+ Mutex_m.define_aliases(singleton_class)
62
67
  end
63
68
  mu_initialize
64
69
  end
65
-
66
- # locking
67
- def mu_synchronize
68
- @mu_mutex.synchronize { yield }
70
+
71
+ # See Mutex#synchronize
72
+ def mu_synchronize(&block)
73
+ @_mutex.synchronize(&block)
69
74
  end
70
-
75
+
76
+ # See Mutex#locked?
71
77
  def mu_locked?
72
- @mu_mutex.locked?
78
+ @_mutex.locked?
73
79
  end
74
-
80
+
81
+ # See Mutex#try_lock
75
82
  def mu_try_lock
76
- @mu_mutex.try_lock
83
+ @_mutex.try_lock
77
84
  end
78
-
85
+
86
+ # See Mutex#lock
79
87
  def mu_lock
80
- @mu_mutex.lock
81
- self
88
+ @_mutex.lock
82
89
  end
83
-
90
+
91
+ # See Mutex#unlock
84
92
  def mu_unlock
85
- @mu_mutex.unlock
86
- self
93
+ @_mutex.unlock
94
+ end
95
+
96
+ # See Mutex#sleep
97
+ def sleep(timeout = nil)
98
+ @_mutex.sleep(timeout)
87
99
  end
88
-
100
+
89
101
  private
90
-
91
- def mu_initialize
92
- @mu_mutex = ::Mutex.new
102
+
103
+ def mu_initialize # :nodoc:
104
+ @_mutex = Mutex.new
93
105
  end
94
106
 
95
- def initialize(*args)
107
+ def initialize(*args) # :nodoc:
96
108
  mu_initialize
97
109
  super
98
110
  end
@@ -1,5 +1,5 @@
1
1
  module RubySL
2
2
  module Mutex_m
3
- VERSION = "1.0.0"
3
+ VERSION = "2.0.0"
4
4
  end
5
5
  end
@@ -19,5 +19,4 @@ Gem::Specification.new do |spec|
19
19
  spec.add_development_dependency "bundler", "~> 1.3"
20
20
  spec.add_development_dependency "rake", "~> 10.0"
21
21
  spec.add_development_dependency "mspec", "~> 1.5"
22
- spec.add_development_dependency "rubysl-prettyprint", "~> 1.0"
23
22
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubysl-mutex_m
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Shirai
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-26 00:00:00.000000000 Z
11
+ date: 2013-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,20 +52,6 @@ dependencies:
52
52
  - - ~>
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.5'
55
- - !ruby/object:Gem::Dependency
56
- name: rubysl-prettyprint
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ~>
60
- - !ruby/object:Gem::Version
61
- version: '1.0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ~>
67
- - !ruby/object:Gem::Version
68
- version: '1.0'
69
55
  description: Ruby standard library mutex_m.
70
56
  email:
71
57
  - brixen@gmail.com