atomic 1.1.2-java → 1.1.4-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/README.rdoc +43 -0
  2. data/atomic.gemspec +14 -9
  3. metadata +83 -58
  4. data/README.md +0 -65
@@ -0,0 +1,43 @@
1
+ = An atomic reference implementation for JRuby, Rubinius, and MRI.
2
+
3
+ == Summary
4
+
5
+ This library provides:
6
+
7
+ * an Atomic class that guarantees atomic updates to its contained value
8
+
9
+ The Atomic class provides accessors for the contained "value" plus two update methods:
10
+
11
+ * update will run the provided block, passing the current value and replacing it with the block result iff the value has not been changed in the mean time. It may run the block repeatedly if there are other concurrent updates in progress.
12
+ * try_update will run the provided block, passing the current value and replacing it with the block result. If the value changes before the update can happen, it will throw Atomic::ConcurrentUpdateError.
13
+
14
+ The atomic repository is at http://github.com/headius/ruby-atomic.
15
+
16
+ == Usage
17
+
18
+ The simplest way to use "atomic" is to call the "update" or "try_update" methods.
19
+
20
+ "try_update" and "update" both call the given block, passing the current value and using the block's result as the new value. If the value is updated by another thread before the block completes, "try update" raises a ConcurrentUpdateError and "update" retries the block. Because "update" may call the block several times when multiple threads are all updating the same value, the block's logic should be kept as simple as possible.
21
+
22
+ require 'atomic'
23
+
24
+ my_atomic = Atomic.new(0)
25
+ my_atomic.update {|v| v + 1}
26
+ begin
27
+ my_atomic.try_update {|v| v + 1}
28
+ rescue Atomic::ConcurrentUpdateError => cue
29
+ # deal with it (retry, propagate, etc)
30
+ end
31
+
32
+ It's also possible to use the regular get/set operations on the Atomic, if you want to avoid the exception and respond to contended changes in some other way.
33
+
34
+ my_atomic = Atomic.new(0)
35
+ my_atomic.value # => 0
36
+ my_atomic.value = 1
37
+ my_atomic.swap(2) # => 1
38
+ my_atomic.compare_and_swap(2, 3) # => true, updated to 3
39
+ my_atomic.compare_and_swap(2, 3) # => false, current is not 2
40
+
41
+ == Building
42
+
43
+ As of 1.1.0, JDK8 is required to build the atomic gem, since it attempts to use the new atomic Unsafe.getAndSetObject method only in JDK8. The resulting code should still work fine as far back as Java 5.
@@ -1,21 +1,26 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
 
3
3
  # Update these to get proper version and commit history
4
- new_version = "1.1.2"
5
- old_version = "1.1.1"
4
+ new_version = "1.1.4"
5
+ old_version = "1.1.0"
6
+
7
+ git_lines = `git log --oneline #{old_version}...#{new_version}`.lines.map {|str| "* #{str}"}.join
8
+ doc_lines = File.readlines("README.rdoc")
9
+ description = <<EOS
10
+ #{doc_lines[0]}
11
+
12
+ == Changes since #{old_version}
13
+
14
+ #{git_lines}
15
+ #{doc_lines[2..-1].join("\n")}
16
+ EOS
6
17
 
7
18
  Gem::Specification.new do |s|
8
19
  s.name = %q{atomic}
9
20
  s.version = new_version
10
21
  s.authors = ["Charles Oliver Nutter", "MenTaLguY", "Sokolov Yura"]
11
22
  s.date = Time.now.strftime('%Y-%m-%d')
12
- s.description = <<EOS
13
- Changes in version #{new_version}:
14
-
15
- #{`git log --oneline #{old_version}...#{new_version}`}
16
- #{`kramdown README.md`}
17
- EOS
18
- puts s.description
23
+ s.description = description
19
24
  s.email = ["headius@headius.com", "mental@rydia.net", "funny.falcon@gmail.com"]
20
25
  s.homepage = "http://github.com/headius/ruby-atomic"
21
26
  s.require_paths = ["lib"]
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: atomic
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
5
4
  prerelease:
5
+ version: 1.1.4
6
6
  platform: java
7
7
  authors:
8
8
  - Charles Oliver Nutter
@@ -11,79 +11,104 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2013-04-05 00:00:00.000000000 Z
14
+ date: 2013-04-06 00:00:00.000000000 Z
15
15
  dependencies: []
16
- description: |+
17
- Changes in version 1.1.2:
16
+ description: |
17
+ = An atomic reference implementation for JRuby, Rubinius, and MRI.
18
18
 
19
19
 
20
- <p>atomic: An atomic reference implementation for JRuby, Rubinius, and MRI.</p>
20
+ == Changes since 1.1.0
21
21
 
22
- <h1 id="summary">Summary</h1>
22
+ * a574b34 More formatting for description.
23
+ * 58d3e34 Convert README to rdoc and try again.
24
+ * f519385 Attempting to get description to look nice on rubygems.org.
25
+ * 2c5ab6c Include README and oneline logs in gem description.
26
+ * 6aeb053 Add @funny-falcon to authors.
27
+ * aa24d4d Bump version to 1.1.1.
28
+ * dc327eb Merge pull request #16 from funny-falcon/patch-1
29
+ * 1b68767 Fix JRUBYREFERENCE8_ALLOCATOR
23
30
 
24
- <p>This library provides:</p>
31
+ == Summary
25
32
 
26
- <ul>
27
- <li>an Atomic class that guarantees atomic updates to its contained value</li>
28
- </ul>
29
33
 
30
- <p>The Atomic class provides accessors for the contained “value” plus two update
31
- methods:</p>
32
34
 
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>
35
+ This library provides:
42
36
 
43
- <p>The atomic repository is at http://github.com/headius/ruby-atomic.</p>
44
37
 
45
- <h1 id="usage">Usage</h1>
46
38
 
47
- <p>The simplest way to use atomic is to call the “update” or “try_update”
48
- methods.</p>
39
+ * an Atomic class that guarantees atomic updates to its contained value
49
40
 
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
54
- the block several times when multiple threads are all updating the same value,
55
- the block’s logic should be kept as simple as possible.</p>
56
41
 
57
- <p>````ruby
58
- require ‘atomic’</p>
59
42
 
60
- <p>my_atomic = Atomic.new(0)
61
- my_atomic.update {|v| v + 1}
62
- begin
63
- my_atomic.try_update {|v| v + 1}
64
- rescue Atomic::ConcurrentUpdateError =&gt; cue
65
- # deal with it (retry, propagate, etc)
66
- end
67
- ````</p>
43
+ The Atomic class provides accessors for the contained "value" plus two update methods:
68
44
 
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>
71
45
 
72
- <p><code>ruby
73
- my_atomic = Atomic.new(0)
74
- my_atomic.value # =&gt; 0
75
- my_atomic.value = 1
76
- my_atomic.swap(2) # =&gt; 1
77
- my_atomic.compare_and_swap(2, 3) # =&gt; true, updated to 3
78
- my_atomic.compare_and_swap(2, 3) # =&gt; false, current is not 2
79
- </code></p>
80
46
 
81
- <h1 id="building">Building</h1>
47
+ * update will run the provided block, passing the current value and replacing it with the block result iff the value has not been changed in the mean time. It may run the block repeatedly if there are other concurrent updates in progress.
82
48
 
83
- <p>As of 1.1.0, JDK8 is required to build the atomic gem, since it attempts to use
84
- the new atomic Unsafe.getAndSetObject method only in JDK8. The resulting code
85
- should still work fine as far back as Java 5.</p>
49
+ * try_update will run the provided block, passing the current value and replacing it with the block result. If the value changes before the update can happen, it will throw Atomic::ConcurrentUpdateError.
86
50
 
51
+
52
+
53
+ The atomic repository is at http://github.com/headius/ruby-atomic.
54
+
55
+
56
+
57
+ == Usage
58
+
59
+
60
+
61
+ The simplest way to use "atomic" is to call the "update" or "try_update" methods.
62
+
63
+
64
+
65
+ "try_update" and "update" both call the given block, passing the current value and using the block's result as the new value. If the value is updated by another thread before the block completes, "try update" raises a ConcurrentUpdateError and "update" retries the block. Because "update" may call the block several times when multiple threads are all updating the same value, the block's logic should be kept as simple as possible.
66
+
67
+
68
+
69
+ require 'atomic'
70
+
71
+
72
+
73
+ my_atomic = Atomic.new(0)
74
+
75
+ my_atomic.update {|v| v + 1}
76
+
77
+ begin
78
+
79
+ my_atomic.try_update {|v| v + 1}
80
+
81
+ rescue Atomic::ConcurrentUpdateError => cue
82
+
83
+ # deal with it (retry, propagate, etc)
84
+
85
+ end
86
+
87
+
88
+
89
+ It's also possible to use the regular get/set operations on the Atomic, if you want to avoid the exception and respond to contended changes in some other way.
90
+
91
+
92
+
93
+ my_atomic = Atomic.new(0)
94
+
95
+ my_atomic.value # => 0
96
+
97
+ my_atomic.value = 1
98
+
99
+ my_atomic.swap(2) # => 1
100
+
101
+ my_atomic.compare_and_swap(2, 3) # => true, updated to 3
102
+
103
+ my_atomic.compare_and_swap(2, 3) # => false, current is not 2
104
+
105
+
106
+
107
+ == Building
108
+
109
+
110
+
111
+ As of 1.1.0, JDK8 is required to build the atomic gem, since it attempts to use the new atomic Unsafe.getAndSetObject method only in JDK8. The resulting code should still work fine as far back as Java 5.
87
112
  email:
88
113
  - headius@headius.com
89
114
  - mental@rydia.net
@@ -97,7 +122,7 @@ files:
97
122
  - .gitignore
98
123
  - .travis.yml
99
124
  - LICENSE
100
- - README.md
125
+ - README.rdoc
101
126
  - Rakefile
102
127
  - atomic.gemspec
103
128
  - examples/atomic_example.rb
@@ -123,17 +148,17 @@ rdoc_options: []
123
148
  require_paths:
124
149
  - lib
125
150
  required_ruby_version: !ruby/object:Gem::Requirement
151
+ none: false
126
152
  requirements:
127
153
  - - '>='
128
154
  - !ruby/object:Gem::Version
129
155
  version: '0'
130
- none: false
131
156
  required_rubygems_version: !ruby/object:Gem::Requirement
157
+ none: false
132
158
  requirements:
133
159
  - - '>='
134
160
  - !ruby/object:Gem::Version
135
161
  version: '0'
136
- none: false
137
162
  requirements: []
138
163
  rubyforge_project:
139
164
  rubygems_version: 1.8.24
data/README.md DELETED
@@ -1,65 +0,0 @@
1
- atomic: An atomic reference implementation for JRuby, Rubinius, and MRI.
2
-
3
- Summary
4
- =======
5
-
6
- This library provides:
7
-
8
- * an Atomic class that guarantees atomic updates to its contained value
9
-
10
- The Atomic class provides accessors for the contained "value" plus two update
11
- methods:
12
-
13
- * update will run the provided block, passing the current value and replacing
14
- it with the block result iff the value has not been changed in the mean time.
15
- It may run the block repeatedly if there are other concurrent updates in
16
- progress.
17
- * try_update will run the provided block, passing the current value and
18
- replacing it with the block result. If the value changes before the update
19
- can happen, it will throw Atomic::ConcurrentUpdateError.
20
-
21
- The atomic repository is at http://github.com/headius/ruby-atomic.
22
-
23
- Usage
24
- =====
25
-
26
- The simplest way to use "atomic" is to call the "update" or "try_update"
27
- methods.
28
-
29
- "try_update" and "update" both call the given block, passing the current
30
- value and using the block's result as the new value. If the value is updated
31
- by another thread before the block completes, "try update" raises a
32
- ConcurrentUpdateError and "update" retries the block. Because "update" may call
33
- the block several times when multiple threads are all updating the same value,
34
- the block's logic should be kept as simple as possible.
35
-
36
- ````ruby
37
- require 'atomic'
38
-
39
- my_atomic = Atomic.new(0)
40
- my_atomic.update {|v| v + 1}
41
- begin
42
- my_atomic.try_update {|v| v + 1}
43
- rescue Atomic::ConcurrentUpdateError => cue
44
- # deal with it (retry, propagate, etc)
45
- end
46
- ````
47
-
48
- It's also possible to use the regular get/set operations on the Atomic, if you
49
- want to avoid the exception and respond to contended changes in some other way.
50
-
51
- ````ruby
52
- my_atomic = Atomic.new(0)
53
- my_atomic.value # => 0
54
- my_atomic.value = 1
55
- my_atomic.swap(2) # => 1
56
- my_atomic.compare_and_swap(2, 3) # => true, updated to 3
57
- my_atomic.compare_and_swap(2, 3) # => false, current is not 2
58
- ````
59
-
60
- Building
61
- ========
62
-
63
- As of 1.1.0, JDK8 is required to build the atomic gem, since it attempts to use
64
- the new atomic Unsafe.getAndSetObject method only in JDK8. The resulting code
65
- should still work fine as far back as Java 5.