atomic 1.1.2 → 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/{README.md → README.rdoc} +5 -7
- data/atomic.gemspec +13 -9
- metadata +36 -31
data/{README.md → README.rdoc}
RENAMED
@@ -1,7 +1,6 @@
|
|
1
|
-
|
1
|
+
= An atomic reference implementation for JRuby, Rubinius, and MRI.
|
2
2
|
|
3
|
-
Summary
|
4
|
-
=======
|
3
|
+
== Summary
|
5
4
|
|
6
5
|
This library provides:
|
7
6
|
|
@@ -20,8 +19,8 @@ methods:
|
|
20
19
|
|
21
20
|
The atomic repository is at http://github.com/headius/ruby-atomic.
|
22
21
|
|
23
|
-
|
24
|
-
|
22
|
+
|
23
|
+
== Usage
|
25
24
|
|
26
25
|
The simplest way to use "atomic" is to call the "update" or "try_update"
|
27
26
|
methods.
|
@@ -57,8 +56,7 @@ my_atomic.compare_and_swap(2, 3) # => true, updated to 3
|
|
57
56
|
my_atomic.compare_and_swap(2, 3) # => false, current is not 2
|
58
57
|
````
|
59
58
|
|
60
|
-
Building
|
61
|
-
========
|
59
|
+
== Building
|
62
60
|
|
63
61
|
As of 1.1.0, JDK8 is required to build the atomic gem, since it attempts to use
|
64
62
|
the new atomic Unsafe.getAndSetObject method only in JDK8. The resulting code
|
data/atomic.gemspec
CHANGED
@@ -1,21 +1,25 @@
|
|
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.3"
|
5
|
+
old_version = "1.1.0"
|
6
|
+
|
7
|
+
lines = File.readlines("README.rdoc")
|
8
|
+
description = <<EOS
|
9
|
+
#{lines[0]}
|
10
|
+
|
11
|
+
== Changes since #{old_version}
|
12
|
+
|
13
|
+
#{`git log --oneline #{old_version}...#{new_version}`}
|
14
|
+
#{lines[0..-1].join("\n")}
|
15
|
+
EOS
|
6
16
|
|
7
17
|
Gem::Specification.new do |s|
|
8
18
|
s.name = %q{atomic}
|
9
19
|
s.version = new_version
|
10
20
|
s.authors = ["Charles Oliver Nutter", "MenTaLguY", "Sokolov Yura"]
|
11
21
|
s.date = Time.now.strftime('%Y-%m-%d')
|
12
|
-
s.description =
|
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
|
22
|
+
s.description = description
|
19
23
|
s.email = ["headius@headius.com", "mental@rydia.net", "funny.falcon@gmail.com"]
|
20
24
|
s.homepage = "http://github.com/headius/ruby-atomic"
|
21
25
|
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.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,35 +13,40 @@ bindir: bin
|
|
13
13
|
cert_chain: []
|
14
14
|
date: 2013-04-05 00:00:00.000000000 Z
|
15
15
|
dependencies: []
|
16
|
-
description: ! "
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
the provided block, passing the current value and\
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
= Atomic.new(0)\nmy_atomic.
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
16
|
+
description: ! "= An atomic reference implementation for JRuby, Rubinius, and MRI.\n\n\n==
|
17
|
+
Changes since 1.1.0\n\n58d3e34 Convert README to rdoc and try again.\nf519385 Attempting
|
18
|
+
to get description to look nice on rubygems.org.\n2c5ab6c Include README and oneline
|
19
|
+
logs in gem description.\n6aeb053 Add @funny-falcon to authors.\naa24d4d Bump version
|
20
|
+
to 1.1.1.\ndc327eb Merge pull request #16 from funny-falcon/patch-1\n1b68767 Fix
|
21
|
+
JRUBYREFERENCE8_ALLOCATOR\n\n= An atomic reference implementation for JRuby, Rubinius,
|
22
|
+
and MRI.\n\n\n\n== Summary\n\n\n\nThis library provides:\n\n\n\n* an Atomic class
|
23
|
+
that guarantees atomic updates to its contained value\n\n\n\nThe Atomic class provides
|
24
|
+
accessors for the contained \"value\" plus two update\n\nmethods:\n\n\n\n* update
|
25
|
+
will run the provided block, passing the current value and replacing\n\n it with
|
26
|
+
the block result iff the value has not been changed in the mean time.\n\n It may
|
27
|
+
run the block repeatedly if there are other concurrent updates in\n\n progress.\n\n*
|
28
|
+
try_update will run the provided block, passing the current value and\n\n replacing
|
29
|
+
it with the block result. If the value changes before the update\n\n can happen,
|
30
|
+
it will throw Atomic::ConcurrentUpdateError.\n\n\n\nThe atomic repository is at
|
31
|
+
http://github.com/headius/ruby-atomic.\n\n\n\n\n\n== Usage\n\n\n\nThe simplest way
|
32
|
+
to use \"atomic\" is to call the \"update\" or \"try_update\"\n\nmethods.\n\n\n\n\"try_update\"
|
33
|
+
and \"update\" both call the given block, passing the current\n\nvalue and using
|
34
|
+
the block's result as the new value. If the value is updated\n\nby another thread
|
35
|
+
before the block completes, \"try update\" raises a\n\nConcurrentUpdateError and
|
36
|
+
\"update\" retries the block. Because \"update\" may call\n\nthe block several times
|
37
|
+
when multiple threads are all updating the same value,\n\nthe block's logic should
|
38
|
+
be kept as simple as possible.\n\n\n\n````ruby\n\nrequire 'atomic'\n\n\n\nmy_atomic
|
39
|
+
= Atomic.new(0)\n\nmy_atomic.update {|v| v + 1}\n\nbegin\n\n my_atomic.try_update
|
40
|
+
{|v| v + 1}\n\nrescue Atomic::ConcurrentUpdateError => cue\n\n # deal with it (retry,
|
41
|
+
propagate, etc)\n\nend\n\n````\n\n\n\nIt's also possible to use the regular get/set
|
42
|
+
operations on the Atomic, if you\n\nwant to avoid the exception and respond to contended
|
43
|
+
changes in some other way.\n\n\n\n````ruby\n\nmy_atomic = Atomic.new(0)\n\nmy_atomic.value
|
44
|
+
# => 0\n\nmy_atomic.value = 1\n\nmy_atomic.swap(2) # => 1\n\nmy_atomic.compare_and_swap(2,
|
45
|
+
3) # => true, updated to 3\n\nmy_atomic.compare_and_swap(2, 3) # => false, current
|
46
|
+
is not 2\n\n````\n\n\n\n== Building\n\n\n\nAs of 1.1.0, JDK8 is required to build
|
47
|
+
the atomic gem, since it attempts to use\n\nthe new atomic Unsafe.getAndSetObject
|
48
|
+
method only in JDK8. The resulting code\n\nshould still work fine as far back as
|
49
|
+
Java 5.\n"
|
45
50
|
email:
|
46
51
|
- headius@headius.com
|
47
52
|
- mental@rydia.net
|
@@ -56,7 +61,7 @@ files:
|
|
56
61
|
- .gitignore
|
57
62
|
- .travis.yml
|
58
63
|
- LICENSE
|
59
|
-
- README.
|
64
|
+
- README.rdoc
|
60
65
|
- Rakefile
|
61
66
|
- atomic.gemspec
|
62
67
|
- examples/atomic_example.rb
|