mutex_m 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.travis.yml +6 -0
- data/Gemfile +5 -0
- data/LICENSE.txt +22 -0
- data/README.md +59 -0
- data/Rakefile +10 -0
- data/bin/console +7 -0
- data/bin/setup +6 -0
- data/lib/mutex_m.rb +116 -0
- data/mutex_m.gemspec +27 -0
- metadata +96 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 2cbc119ce68a11fe9437d7996558cbe8442a70993f81c041a3d275ce72190781
|
4
|
+
data.tar.gz: 92174be4a48caf6bb633a5eacf27913a67a48bc0fca21dee595173692f5decc7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: '068be6b85e50d6ea6c01856db3b451f626f8fbbbb60a4d3bf8645a84ae8e89becb910bfc6d5aecc5a957549661caa161a58818b7d5bba871ef5e0784f7f8ae48'
|
7
|
+
data.tar.gz: 44677a56e80a8ef21f4bc12bd2d750b4a51935f2c71ed33b0a2d70921ce7a378068c125f47132111608dd7020d767ece9bca4a8c3e7e244a224eb7076fdfa9fe
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (C) 1993-2013 Yukihiro Matsumoto. All rights reserved.
|
2
|
+
|
3
|
+
Redistribution and use in source and binary forms, with or without
|
4
|
+
modification, are permitted provided that the following conditions
|
5
|
+
are met:
|
6
|
+
1. Redistributions of source code must retain the above copyright
|
7
|
+
notice, this list of conditions and the following disclaimer.
|
8
|
+
2. Redistributions in binary form must reproduce the above copyright
|
9
|
+
notice, this list of conditions and the following disclaimer in the
|
10
|
+
documentation and/or other materials provided with the distribution.
|
11
|
+
|
12
|
+
THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
13
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
14
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
15
|
+
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
16
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
17
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
18
|
+
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
19
|
+
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
20
|
+
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
21
|
+
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
22
|
+
SUCH DAMAGE.
|
data/README.md
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# Mutex_m
|
2
|
+
|
3
|
+
When 'mutex_m' is required, any object that extends or includes Mutex_m will be treated like a Mutex.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'mutex_m'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install mutex_m
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Start by requiring the standard library Mutex_m:
|
24
|
+
|
25
|
+
```
|
26
|
+
require "mutex_m.rb"
|
27
|
+
```
|
28
|
+
|
29
|
+
From here you can extend an object with Mutex instance methods:
|
30
|
+
|
31
|
+
```
|
32
|
+
obj = Object.new
|
33
|
+
obj.extend Mutex_m
|
34
|
+
```
|
35
|
+
|
36
|
+
Or mixin Mutex_m into your module to your class inherit Mutex instance methods.
|
37
|
+
|
38
|
+
```
|
39
|
+
class Foo
|
40
|
+
include Mutex_m
|
41
|
+
# ...
|
42
|
+
end
|
43
|
+
obj = Foo.new
|
44
|
+
# this obj can be handled like Mutex
|
45
|
+
g```
|
46
|
+
|
47
|
+
## Development
|
48
|
+
|
49
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
50
|
+
|
51
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
52
|
+
|
53
|
+
## Contributing
|
54
|
+
|
55
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/ruby/mutex_m.
|
56
|
+
|
57
|
+
## License
|
58
|
+
|
59
|
+
The gem is available as open source under the terms of the [2-Clause BSD License](https://opensource.org/licenses/BSD-2-Clause).
|
data/Rakefile
ADDED
data/bin/console
ADDED
data/bin/setup
ADDED
data/lib/mutex_m.rb
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
# frozen_string_literal: false
|
2
|
+
#
|
3
|
+
# mutex_m.rb -
|
4
|
+
# $Release Version: 3.0$
|
5
|
+
# $Revision: 1.7 $
|
6
|
+
# Original from mutex.rb
|
7
|
+
# by Keiju ISHITSUKA(keiju@ishitsuka.com)
|
8
|
+
# modified by matz
|
9
|
+
# patched by akira yamada
|
10
|
+
#
|
11
|
+
# --
|
12
|
+
|
13
|
+
# = mutex_m.rb
|
14
|
+
#
|
15
|
+
# When 'mutex_m' is required, any object that extends or includes Mutex_m will
|
16
|
+
# be treated like a Mutex.
|
17
|
+
#
|
18
|
+
# Start by requiring the standard library Mutex_m:
|
19
|
+
#
|
20
|
+
# require "mutex_m.rb"
|
21
|
+
#
|
22
|
+
# From here you can extend an object with Mutex instance methods:
|
23
|
+
#
|
24
|
+
# obj = Object.new
|
25
|
+
# obj.extend Mutex_m
|
26
|
+
#
|
27
|
+
# Or mixin Mutex_m into your module to your class inherit Mutex instance
|
28
|
+
# methods --- remember to call super() in your class initialize method.
|
29
|
+
#
|
30
|
+
# class Foo
|
31
|
+
# include Mutex_m
|
32
|
+
# def initialize
|
33
|
+
# # ...
|
34
|
+
# super()
|
35
|
+
# end
|
36
|
+
# # ...
|
37
|
+
# end
|
38
|
+
# obj = Foo.new
|
39
|
+
# # this obj can be handled like Mutex
|
40
|
+
#
|
41
|
+
module Mutex_m
|
42
|
+
|
43
|
+
VERSION = "0.1.0"
|
44
|
+
|
45
|
+
def Mutex_m.define_aliases(cl) # :nodoc:
|
46
|
+
cl.module_eval %q{
|
47
|
+
alias locked? mu_locked?
|
48
|
+
alias lock mu_lock
|
49
|
+
alias unlock mu_unlock
|
50
|
+
alias try_lock mu_try_lock
|
51
|
+
alias synchronize mu_synchronize
|
52
|
+
}
|
53
|
+
end
|
54
|
+
|
55
|
+
def Mutex_m.append_features(cl) # :nodoc:
|
56
|
+
super
|
57
|
+
define_aliases(cl) unless cl.instance_of?(Module)
|
58
|
+
end
|
59
|
+
|
60
|
+
def Mutex_m.extend_object(obj) # :nodoc:
|
61
|
+
super
|
62
|
+
obj.mu_extended
|
63
|
+
end
|
64
|
+
|
65
|
+
def mu_extended # :nodoc:
|
66
|
+
unless (defined? locked? and
|
67
|
+
defined? lock and
|
68
|
+
defined? unlock and
|
69
|
+
defined? try_lock and
|
70
|
+
defined? synchronize)
|
71
|
+
Mutex_m.define_aliases(singleton_class)
|
72
|
+
end
|
73
|
+
mu_initialize
|
74
|
+
end
|
75
|
+
|
76
|
+
# See Mutex#synchronize
|
77
|
+
def mu_synchronize(&block)
|
78
|
+
@_mutex.synchronize(&block)
|
79
|
+
end
|
80
|
+
|
81
|
+
# See Mutex#locked?
|
82
|
+
def mu_locked?
|
83
|
+
@_mutex.locked?
|
84
|
+
end
|
85
|
+
|
86
|
+
# See Mutex#try_lock
|
87
|
+
def mu_try_lock
|
88
|
+
@_mutex.try_lock
|
89
|
+
end
|
90
|
+
|
91
|
+
# See Mutex#lock
|
92
|
+
def mu_lock
|
93
|
+
@_mutex.lock
|
94
|
+
end
|
95
|
+
|
96
|
+
# See Mutex#unlock
|
97
|
+
def mu_unlock
|
98
|
+
@_mutex.unlock
|
99
|
+
end
|
100
|
+
|
101
|
+
# See Mutex#sleep
|
102
|
+
def sleep(timeout = nil)
|
103
|
+
@_mutex.sleep(timeout)
|
104
|
+
end
|
105
|
+
|
106
|
+
private
|
107
|
+
|
108
|
+
def mu_initialize # :nodoc:
|
109
|
+
@_mutex = Thread::Mutex.new
|
110
|
+
end
|
111
|
+
|
112
|
+
def initialize(*args) # :nodoc:
|
113
|
+
mu_initialize
|
114
|
+
super
|
115
|
+
end
|
116
|
+
end
|
data/mutex_m.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
begin
|
2
|
+
require_relative "lib/mutex_m"
|
3
|
+
rescue LoadError
|
4
|
+
# for Ruby core repository
|
5
|
+
require_relative "mutex_m"
|
6
|
+
end
|
7
|
+
|
8
|
+
Gem::Specification.new do |spec|
|
9
|
+
spec.name = "mutex_m"
|
10
|
+
spec.version = Mutex_m::VERSION
|
11
|
+
spec.authors = ["Keiju ISHITSUKA"]
|
12
|
+
spec.email = ["keiju@ruby-lang.org"]
|
13
|
+
|
14
|
+
spec.summary = %q{Mixin to extend objects to be handled like a Mutex.}
|
15
|
+
spec.description = %q{Mixin to extend objects to be handled like a Mutex.}
|
16
|
+
spec.homepage = "https://github.com/ruby/mutex_m"
|
17
|
+
spec.license = "BSD-2-Clause"
|
18
|
+
|
19
|
+
spec.files = [".gitignore", ".travis.yml", "Gemfile", "LICENSE.txt", "README.md", "Rakefile", "bin/console", "bin/setup", "lib/mutex_m.rb", "mutex_m.gemspec"]
|
20
|
+
spec.bindir = "exe"
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler"
|
25
|
+
spec.add_development_dependency "rake"
|
26
|
+
spec.add_development_dependency "test-unit"
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mutex_m
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Keiju ISHITSUKA
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-12-04 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: test-unit
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Mixin to extend objects to be handled like a Mutex.
|
56
|
+
email:
|
57
|
+
- keiju@ruby-lang.org
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".travis.yml"
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE.txt
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- bin/console
|
69
|
+
- bin/setup
|
70
|
+
- lib/mutex_m.rb
|
71
|
+
- mutex_m.gemspec
|
72
|
+
homepage: https://github.com/ruby/mutex_m
|
73
|
+
licenses:
|
74
|
+
- BSD-2-Clause
|
75
|
+
metadata: {}
|
76
|
+
post_install_message:
|
77
|
+
rdoc_options: []
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
requirements: []
|
91
|
+
rubyforge_project:
|
92
|
+
rubygems_version: 2.7.6
|
93
|
+
signing_key:
|
94
|
+
specification_version: 4
|
95
|
+
summary: Mixin to extend objects to be handled like a Mutex.
|
96
|
+
test_files: []
|