Skip to content

Commit b29d396

Browse files
committed
Returned AbortError to TVar.
1 parent 03f0d51 commit b29d396

File tree

3 files changed

+5
-8
lines changed

3 files changed

+5
-8
lines changed

lib/concurrent/errors.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
module Concurrent
22

3-
# Raised when a complex and atomic operation, such as a transaction,
4-
# is aborted prior to completion.
5-
AbortError = Class.new(StandardError)
6-
73
# Raised when errors occur during configuration.
84
ConfigurationError = Class.new(StandardError)
95

lib/concurrent/tvar.rb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
require 'set'
22

3-
require 'concurrent/errors'
43
require 'concurrent/atomic/thread_local_var'
54

65
module Concurrent
@@ -110,7 +109,7 @@ def atomically
110109

111110
begin
112111
result = yield
113-
rescue Concurrent::AbortError => e
112+
rescue Transaction::AbortError => e
114113
transaction.abort
115114
result = Transaction::ABORTED
116115
rescue => e
@@ -139,7 +138,7 @@ def atomically
139138

140139
# Abort a currently running transaction - see `Concurrent::atomically`.
141140
def abort_transaction
142-
raise Concurrent::AbortError.new
141+
raise Transaction::AbortError.new
143142
end
144143

145144
module_function :atomically, :abort_transaction
@@ -155,6 +154,8 @@ class Transaction
155154
ReadLogEntry = Struct.new(:tvar, :version)
156155
UndoLogEntry = Struct.new(:tvar, :value)
157156

157+
AbortError = Class.new(StandardError)
158+
158159
def initialize
159160
@write_set = Set.new
160161
@read_log = []

spec/concurrent/tvar_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ module Concurrent
129129
describe '#abort_transaction' do
130130

131131
it 'raises an exception outside an #atomically block' do
132-
expect { Concurrent::abort_transaction }.to raise_error(Concurrent::AbortError)
132+
expect { Concurrent::abort_transaction }.to raise_error(Concurrent::Transaction::AbortError)
133133
end
134134

135135
end

0 commit comments

Comments
 (0)