aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/lib
diff options
context:
space:
mode:
Diffstat (limited to 'actionview/lib')
-rw-r--r--actionview/lib/action_view/cache_expiry.rb19
1 files changed, 11 insertions, 8 deletions
diff --git a/actionview/lib/action_view/cache_expiry.rb b/actionview/lib/action_view/cache_expiry.rb
index 820afc093d..3d8ffeaefb 100644
--- a/actionview/lib/action_view/cache_expiry.rb
+++ b/actionview/lib/action_view/cache_expiry.rb
@@ -16,18 +16,21 @@ module ActionView
@watched_dirs = nil
@watcher_class = watcher
@watcher = nil
+ @mutex = Mutex.new
end
def clear_cache_if_necessary
- watched_dirs = dirs_to_watch
- if watched_dirs != @watched_dirs
- @watched_dirs = watched_dirs
- @watcher = @watcher_class.new([], watched_dirs) do
- clear_cache
+ @mutex.synchronize do
+ watched_dirs = dirs_to_watch
+ if watched_dirs != @watched_dirs
+ @watched_dirs = watched_dirs
+ @watcher = @watcher_class.new([], watched_dirs) do
+ clear_cache
+ end
+ @watcher.execute
+ else
+ @watcher.execute_if_updated
end
- @watcher.execute
- else
- @watcher.execute_if_updated
end
end