Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Commit 8bb78a7

Browse files
committed
Prefer Ruby core Mutex to our local copy
1 parent e42f72b commit 8bb78a7

File tree

4 files changed

+1
-108
lines changed

4 files changed

+1
-108
lines changed

.rubocop.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@ Style/EvalWithLocation:
1919
# eval is only used here to check syntax
2020
- 'lib/rspec/support/ruby_features.rb'
2121

22-
Lint/AssignmentInCondition:
23-
Exclude:
24-
# The pattern makes sense here
25-
- 'lib/rspec/support/mutex.rb'
26-
2722
# Over time we'd like to get this down, but this is what we're at now.
2823
Metrics/AbcSize:
2924
Max: 22

lib/rspec/support/mutex.rb

Lines changed: 0 additions & 73 deletions
This file was deleted.

lib/rspec/support/reentrant_mutex.rb

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,12 @@ module Support
66
# Based on Monitor as of 2.2 -
77
# https://github.com/ruby/ruby/blob/eb7ddaa3a47bf48045d26c72eb0f263a53524ebc/lib/monitor.rb#L9
88
#
9-
# Depends on Mutex, but Mutex is only available as part of core since 1.9.1:
10-
# exists - http://ruby-doc.org/core-1.9.1/Mutex.html
11-
# dne - http://ruby-doc.org/core-1.9.0/Mutex.html
12-
#
139
# @private
1410
class ReentrantMutex
1511
def initialize
1612
@owner = nil
1713
@count = 0
18-
@mutex = Mutex.new
14+
@mutex = Thread::Mutex.new
1915
end
2016

2117
def synchronize
@@ -40,22 +36,5 @@ def exit
4036
@mutex.unlock
4137
end
4238
end
43-
44-
if defined? ::Mutex
45-
# On 1.9 and up, this is in core, so we just use the real one
46-
class Mutex < ::Mutex
47-
# If you mock Mutex.new you break our usage of Mutex, so
48-
# instead we capture the original method to return Mutexs.
49-
NEW_MUTEX_METHOD = Mutex.method(:new)
50-
51-
def self.new
52-
NEW_MUTEX_METHOD.call
53-
end
54-
end
55-
else # For 1.8.7
56-
# :nocov:
57-
RSpec::Support.require_rspec_support "mutex"
58-
# :nocov:
59-
end
6039
end
6140
end

spec/rspec/support/mutex_spec.rb

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)