Module: Rhales::Ruequire
- Defined in:
- lib/rhales/refinements/require_refinements.rb
Class Method Summary collapse
-
.cleanup_file_watchers! ⇒ Object
Stop all file watchers and clean up resources.
-
.clear_cache! ⇒ Object
Clear cache (useful for development and testing).
-
.disable_file_watching! ⇒ Object
Disable file watching.
-
.enable_file_watching! ⇒ Object
Enable development mode file watching.
-
.file_watchers ⇒ Object
Thread-safe access to file watchers.
-
.file_watching_enabled? ⇒ Boolean
-
.rsfc_cache ⇒ Object
Thread-safe access to cache.
-
.stop_watching_file!(full_path) ⇒ Object
Stop watching a specific file.
Class Method Details
.cleanup_file_watchers! ⇒ Object
Stop all file watchers and clean up resources
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/rhales/refinements/require_refinements.rb', line 31 def cleanup_file_watchers! @watchers_mutex.synchronize do @file_watchers.each_value do |watcher_thread| next unless watcher_thread.is_a?(Thread) && watcher_thread.alive? watcher_thread.kill begin watcher_thread.join(1) # Wait up to 1 second for clean shutdown rescue StandardError # Thread might already be dead, ignore errors end end @file_watchers.clear end end |
.clear_cache! ⇒ Object
Clear cache (useful for development and testing)
25 26 27 28 |
# File 'lib/rhales/refinements/require_refinements.rb', line 25 def clear_cache! @cache_mutex.synchronize { @rsfc_cache.clear } cleanup_file_watchers! end |
.disable_file_watching! ⇒ Object
Disable file watching
68 69 70 |
# File 'lib/rhales/refinements/require_refinements.rb', line 68 def disable_file_watching! @file_watching_enabled = false end |
.enable_file_watching! ⇒ Object
Enable development mode file watching
63 64 65 |
# File 'lib/rhales/refinements/require_refinements.rb', line 63 def enable_file_watching! @file_watching_enabled = true end |
.file_watchers ⇒ Object
Thread-safe access to file watchers
20 21 22 |
# File 'lib/rhales/refinements/require_refinements.rb', line 20 def file_watchers @watchers_mutex.synchronize { @file_watchers.dup } end |
.file_watching_enabled? ⇒ Boolean
72 73 74 |
# File 'lib/rhales/refinements/require_refinements.rb', line 72 def file_watching_enabled? @file_watching_enabled ||= false end |
.rsfc_cache ⇒ Object
Thread-safe access to cache
15 16 17 |
# File 'lib/rhales/refinements/require_refinements.rb', line 15 def rsfc_cache @cache_mutex.synchronize { @rsfc_cache.dup } end |
.stop_watching_file!(full_path) ⇒ Object
Stop watching a specific file
48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/rhales/refinements/require_refinements.rb', line 48 def stop_watching_file!(full_path) @watchers_mutex.synchronize do watcher_thread = @file_watchers.delete(full_path) if watcher_thread.is_a?(Thread) && watcher_thread.alive? watcher_thread.kill begin watcher_thread.join(1) rescue StandardError # Thread cleanup error, ignore end end end end |