atomic 1.1.1-java → 1.1.2-java
Sign up to get free protection for your applications and to get access to all the features.
- data/atomic.gemspec +4 -3
- metadata +48 -51
data/atomic.gemspec
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
|
3
3
|
# Update these to get proper version and commit history
|
4
|
-
new_version = "1.1.
|
5
|
-
old_version = "1.1.
|
4
|
+
new_version = "1.1.2"
|
5
|
+
old_version = "1.1.1"
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = %q{atomic}
|
@@ -13,8 +13,9 @@ Gem::Specification.new do |s|
|
|
13
13
|
Changes in version #{new_version}:
|
14
14
|
|
15
15
|
#{`git log --oneline #{old_version}...#{new_version}`}
|
16
|
-
#{
|
16
|
+
#{`kramdown README.md`}
|
17
17
|
EOS
|
18
|
+
puts s.description
|
18
19
|
s.email = ["headius@headius.com", "mental@rydia.net", "funny.falcon@gmail.com"]
|
19
20
|
s.homepage = "http://github.com/headius/ruby-atomic"
|
20
21
|
s.require_paths = ["lib"]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: atomic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: java
|
7
7
|
authors:
|
@@ -13,80 +13,77 @@ bindir: bin
|
|
13
13
|
cert_chain: []
|
14
14
|
date: 2013-04-05 00:00:00.000000000 Z
|
15
15
|
dependencies: []
|
16
|
-
description:
|
17
|
-
Changes in version 1.1.
|
16
|
+
description: |+
|
17
|
+
Changes in version 1.1.2:
|
18
18
|
|
19
|
-
2c5ab6c Include README and oneline logs in gem description.
|
20
|
-
6aeb053 Add @funny-falcon to authors.
|
21
|
-
aa24d4d Bump version to 1.1.1.
|
22
|
-
dc327eb Merge pull request #16 from funny-falcon/patch-1
|
23
|
-
1b68767 Fix JRUBYREFERENCE8_ALLOCATOR
|
24
19
|
|
25
|
-
atomic: An atomic reference implementation for JRuby, Rubinius, and MRI
|
20
|
+
<p>atomic: An atomic reference implementation for JRuby, Rubinius, and MRI.</p>
|
26
21
|
|
27
|
-
Summary
|
28
|
-
=======
|
22
|
+
<h1 id="summary">Summary</h1>
|
29
23
|
|
30
|
-
This library provides
|
24
|
+
<p>This library provides:</p>
|
31
25
|
|
32
|
-
|
26
|
+
<ul>
|
27
|
+
<li>an Atomic class that guarantees atomic updates to its contained value</li>
|
28
|
+
</ul>
|
33
29
|
|
34
|
-
The Atomic class provides accessors for the contained
|
35
|
-
methods
|
30
|
+
<p>The Atomic class provides accessors for the contained “value” plus two update
|
31
|
+
methods:</p>
|
36
32
|
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
33
|
+
<ul>
|
34
|
+
<li>update will run the provided block, passing the current value and replacing
|
35
|
+
it with the block result iff the value has not been changed in the mean time.
|
36
|
+
It may run the block repeatedly if there are other concurrent updates in
|
37
|
+
progress.</li>
|
38
|
+
<li>try_update will run the provided block, passing the current value and
|
39
|
+
replacing it with the block result. If the value changes before the update
|
40
|
+
can happen, it will throw Atomic::ConcurrentUpdateError.</li>
|
41
|
+
</ul>
|
44
42
|
|
45
|
-
The atomic repository is at http://github.com/headius/ruby-atomic
|
43
|
+
<p>The atomic repository is at http://github.com/headius/ruby-atomic.</p>
|
46
44
|
|
47
|
-
Usage
|
48
|
-
=====
|
45
|
+
<h1 id="usage">Usage</h1>
|
49
46
|
|
50
|
-
The simplest way to use
|
51
|
-
methods
|
47
|
+
<p>The simplest way to use “atomic” is to call the “update” or “try_update”
|
48
|
+
methods.</p>
|
52
49
|
|
53
|
-
|
54
|
-
value and using the block
|
55
|
-
by another thread before the block completes,
|
56
|
-
ConcurrentUpdateError and
|
50
|
+
<p>“try_update” and “update” both call the given block, passing the current
|
51
|
+
value and using the block’s result as the new value. If the value is updated
|
52
|
+
by another thread before the block completes, “try update” raises a
|
53
|
+
ConcurrentUpdateError and “update” retries the block. Because “update” may call
|
57
54
|
the block several times when multiple threads are all updating the same value,
|
58
|
-
the block
|
55
|
+
the block’s logic should be kept as simple as possible.</p>
|
59
56
|
|
60
|
-
|
61
|
-
require
|
57
|
+
<p>````ruby
|
58
|
+
require ‘atomic’</p>
|
62
59
|
|
63
|
-
my_atomic = Atomic.new(0)
|
60
|
+
<p>my_atomic = Atomic.new(0)
|
64
61
|
my_atomic.update {|v| v + 1}
|
65
62
|
begin
|
66
63
|
my_atomic.try_update {|v| v + 1}
|
67
|
-
rescue Atomic::ConcurrentUpdateError
|
64
|
+
rescue Atomic::ConcurrentUpdateError => cue
|
68
65
|
# deal with it (retry, propagate, etc)
|
69
66
|
end
|
70
|
-
|
67
|
+
````</p>
|
71
68
|
|
72
|
-
It
|
73
|
-
want to avoid the exception and respond to contended changes in some other way
|
69
|
+
<p>It’s also possible to use the regular get/set operations on the Atomic, if you
|
70
|
+
want to avoid the exception and respond to contended changes in some other way.</p>
|
74
71
|
|
75
|
-
|
72
|
+
<p><code>ruby
|
76
73
|
my_atomic = Atomic.new(0)
|
77
|
-
my_atomic.value #
|
74
|
+
my_atomic.value # => 0
|
78
75
|
my_atomic.value = 1
|
79
|
-
my_atomic.swap(2) #
|
80
|
-
my_atomic.compare_and_swap(2, 3) #
|
81
|
-
my_atomic.compare_and_swap(2, 3) #
|
82
|
-
|
76
|
+
my_atomic.swap(2) # => 1
|
77
|
+
my_atomic.compare_and_swap(2, 3) # => true, updated to 3
|
78
|
+
my_atomic.compare_and_swap(2, 3) # => false, current is not 2
|
79
|
+
</code></p>
|
83
80
|
|
84
|
-
Building
|
85
|
-
========
|
81
|
+
<h1 id="building">Building</h1>
|
86
82
|
|
87
|
-
As of 1.1.0, JDK8 is required to build the atomic gem, since it attempts to use
|
83
|
+
<p>As of 1.1.0, JDK8 is required to build the atomic gem, since it attempts to use
|
88
84
|
the new atomic Unsafe.getAndSetObject method only in JDK8. The resulting code
|
89
|
-
should still work fine as far back as Java 5
|
85
|
+
should still work fine as far back as Java 5.</p>
|
86
|
+
|
90
87
|
email:
|
91
88
|
- headius@headius.com
|
92
89
|
- mental@rydia.net
|
@@ -126,17 +123,17 @@ rdoc_options: []
|
|
126
123
|
require_paths:
|
127
124
|
- lib
|
128
125
|
required_ruby_version: !ruby/object:Gem::Requirement
|
129
|
-
none: false
|
130
126
|
requirements:
|
131
127
|
- - '>='
|
132
128
|
- !ruby/object:Gem::Version
|
133
129
|
version: '0'
|
134
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
135
130
|
none: false
|
131
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
136
132
|
requirements:
|
137
133
|
- - '>='
|
138
134
|
- !ruby/object:Gem::Version
|
139
135
|
version: '0'
|
136
|
+
none: false
|
140
137
|
requirements: []
|
141
138
|
rubyforge_project:
|
142
139
|
rubygems_version: 1.8.24
|