Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop dependency on mutex_m #703

Merged
merged 1 commit into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading