Skip to content

Commit 31cdd3c

Browse files
iankspitr-ch
authored andcommitted
Move AtomicMarkableReference out of Edge
1 parent a9e07bf commit 31cdd3c

File tree

6 files changed

+10
-10
lines changed

6 files changed

+10
-10
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ Thread-safe variables:
108108
* [ReadWriteLock](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/ReadWriteLock.html) A lock that supports multiple readers but only one writer.
109109
* [ReentrantReadWriteLock](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/ReentrantReadWriteLock.html) A read/write lock with reentrant and upgrade features.
110110
* [Semaphore](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/Semaphore.html) A counting-based locking mechanism that uses permits.
111+
* [AtomicMarkableReference](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/Atomic/AtomicMarkableReference.html)
111112

112113
### Edge Features
113114

@@ -129,7 +130,6 @@ be obeyed though. Features developed in `concurrent-ruby-edge` are expected to m
129130
Functionally equivalent to Go [channels](https://tour.golang.org/concurrency/2) with additional
130131
inspiration from Clojure [core.async](https://clojure.github.io/core.async/).
131132
* [LazyRegister](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/LazyRegister.html)
132-
* [AtomicMarkableReference](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/Edge/AtomicMarkableReference.html)
133133
* [LockFreeLinkedSet](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/Edge/LockFreeLinkedSet.html)
134134
* [LockFreeStack](http://ruby-concurrency.github.io/concurrent-ruby/Concurrent/LockFreeStack.html)
135135

lib/concurrent-edge.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
require 'concurrent/exchanger'
77
require 'concurrent/lazy_register'
88

9-
require 'concurrent/edge/atomic_markable_reference'
109
require 'concurrent/edge/lock_free_linked_set'
1110
require 'concurrent/edge/lock_free_queue'
1211
require 'concurrent/edge/lock_free_stack'

lib/concurrent.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
require 'concurrent/executors'
88
require 'concurrent/synchronization'
99

10+
require 'concurrent/atomic/atomic_markable_reference'
1011
require 'concurrent/atomic/atomic_reference'
1112
require 'concurrent/agent'
1213
require 'concurrent/atom'

lib/concurrent/edge/atomic_markable_reference.rb renamed to lib/concurrent/atomic/atomic_markable_reference.rb

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
module Concurrent
2-
module Edge
3-
2+
module Atomic
43
# @!macro [attach] atomic_markable_reference
54
#
65
# An atomic reference which maintains an object reference along with a mark bit
@@ -144,9 +143,9 @@ def try_update!
144143

145144
unless compare_and_set old_val, new_val, old_mark, new_mark
146145
fail ::Concurrent::ConcurrentUpdateError,
147-
'AtomicMarkableReference: Update failed due to race condition.',
148-
'Note: If you would like to guarantee an update, please use ' \
149-
'the `AtomicMarkableReference#update` method.'
146+
'AtomicMarkableReference: Update failed due to race condition.',
147+
'Note: If you would like to guarantee an update, please use ' \
148+
'the `AtomicMarkableReference#update` method.'
150149
end
151150

152151
ImmutableArray[new_val, new_mark]

lib/concurrent/edge/lock_free_linked_set/node.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
require 'concurrent/edge/atomic_markable_reference'
1+
require 'concurrent/atomic/atomic_markable_reference'
22

33
module Concurrent
44
module Edge
55
class LockFreeLinkedSet
66
class Node < Synchronization::Object
77
include Comparable
8+
include Concurrent::Atomic
89

910
safe_initialization!
1011

1112
def initialize(data = nil, successor = nil)
1213
super()
13-
@SuccessorReference = AtomicMarkableReference.new(successor || Tail.new)
14+
@SuccessorReference = AtomicMarkableReference.new(successor || Tail.new)
1415
@Data = data
1516
@Key = key_for data
1617
end

spec/concurrent/atomic/atomic_markable_reference_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
RSpec.describe Concurrent::Edge::AtomicMarkableReference do
1+
RSpec.describe Concurrent::Atomic::AtomicMarkableReference do
22
subject { described_class.new 1000, true }
33

44
describe '.initialize' do

0 commit comments

Comments
 (0)