Skip to content

Commit

Permalink
Drop dependency on mutex_m
Browse files Browse the repository at this point in the history
It doesn't really save much effort, and it's being
extracted as a gem which cause issues for projects
like spring that often are loaded before bundler.
  • Loading branch information
byroot committed Nov 14, 2023
1 parent 6b2001f commit 4a5368c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 10 deletions.
10 changes: 3 additions & 7 deletions lib/spring/watcher/abstract.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
require "pathname"
require "mutex_m"

module Spring
module Watcher
Expand All @@ -9,13 +8,10 @@ module Watcher
# IO.select([watcher]) # watcher is running in background
# watcher.stale? # => true
class Abstract
include Mutex_m

attr_reader :files, :directories, :root, :latency

def initialize(root, latency)
super()

@mutex = Mutex.new
@root = File.realpath(root)
@latency = latency
@files = {}
Expand Down Expand Up @@ -59,7 +55,7 @@ def add(*items)
end
end

synchronize {
@mutex.synchronize do
items.each do |item|
if item.directory?
directories[item.realpath.to_s] = true
Expand All @@ -75,7 +71,7 @@ def add(*items)
end

subjects_changed
}
end
end

def stale?
Expand Down
2 changes: 1 addition & 1 deletion lib/spring/watcher/polling.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def initialize(root, latency)
end

def check_stale
synchronize do
@mutex.synchronize do
computed = compute_mtime
if mtime < computed
debug { "check_stale: mtime=#{mtime.inspect} < computed=#{computed.inspect}" }
Expand Down
2 changes: 0 additions & 2 deletions spring.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ Gem::Specification.new do |gem|

gem.required_ruby_version = ">= 2.7.0"

gem.add_dependency 'mutex_m'

gem.add_development_dependency 'rake'
gem.add_development_dependency 'bump'
gem.add_development_dependency 'activesupport'
Expand Down

0 comments on commit 4a5368c

Please sign in to comment.