watcher_init Subroutine

private subroutine watcher_init(self, cfg)

Initialize a watcher instance from configuration.

This routine: - Applies low-CPU mode selection to the sleep implementation. - Enables requested feature plugins and calls their init/start callbacks. - Builds the initial watch list and fingerprints. - Optionally performs an initial run (w%run_on_start).

Type Bound

watcher_t

Arguments

Type IntentOptional Attributes Name
class(watcher_t), intent(inout) :: self
type(watch_config_t), intent(in) :: cfg

Calls

proc~~watcher_init~~CallsGraph proc~watcher_init watcher_t%watcher_init proc~enable_features enable_features proc~watcher_init->proc~enable_features proc~init_all feature_manager_t%init_all proc~watcher_init->proc~init_all proc~on_start_all feature_manager_t%on_start_all proc~watcher_init->proc~on_start_all proc~rebuild_watch_list rebuild_watch_list proc~watcher_init->proc~rebuild_watch_list proc~run_once run_once proc~watcher_init->proc~run_once proc~set_low_cpu set_low_cpu proc~watcher_init->proc~set_low_cpu proc~add_stats add_stats proc~enable_features->proc~add_stats proc~log_warn log_warn proc~enable_features->proc~log_warn proc~feat_init_noop watch_feature_t%feat_init_noop proc~init_all->proc~feat_init_noop proc~feat_noop watch_feature_t%feat_noop proc~on_start_all->proc~feat_noop proc~compute_watch_files_from_settings compute_watch_files_from_settings proc~rebuild_watch_list->proc~compute_watch_files_from_settings proc~ftoa ftoa proc~rebuild_watch_list->proc~ftoa proc~init_fingerprints init_fingerprints proc~rebuild_watch_list->proc~init_fingerprints proc~log_info log_info proc~rebuild_watch_list->proc~log_info proc~manifest_key_from_files manifest_key_from_files proc~rebuild_watch_list->proc~manifest_key_from_files proc~on_watch_list_built_all feature_manager_t%on_watch_list_built_all proc~rebuild_watch_list->proc~on_watch_list_built_all proc~print_banner print_banner proc~rebuild_watch_list->proc~print_banner proc~print_file_list print_file_list proc~rebuild_watch_list->proc~print_file_list str str proc~rebuild_watch_list->str proc~on_after_run_all feature_manager_t%on_after_run_all proc~run_once->proc~on_after_run_all proc~on_before_run_all feature_manager_t%on_before_run_all proc~run_once->proc~on_before_run_all proc~run_command_and_report run_command_and_report proc~run_once->proc~run_command_and_report proc~fm_add feature_manager_t%fm_add proc~add_stats->proc~fm_add proc~new_stats_feature new_stats_feature proc~add_stats->proc~new_stats_feature proc~compute_watch_files_from_settings->proc~ftoa proc~compute_watch_files_from_settings->proc~log_info proc~compute_watch_files_from_settings->str add add proc~compute_watch_files_from_settings->add basename basename proc~compute_watch_files_from_settings->basename build_model build_model proc~compute_watch_files_from_settings->build_model dep dep proc~compute_watch_files_from_settings->dep get_package_data get_package_data proc~compute_watch_files_from_settings->get_package_data is_executable_target is_executable_target proc~compute_watch_files_from_settings->is_executable_target join_path join_path proc~compute_watch_files_from_settings->join_path new_dependency_tree new_dependency_tree proc~compute_watch_files_from_settings->new_dependency_tree proc~dfs_mark_bool dfs_mark_bool proc~compute_watch_files_from_settings->proc~dfs_mark_bool proc~dfs_mark_mask dfs_mark_mask proc~compute_watch_files_from_settings->proc~dfs_mark_mask proc~filter_watch_files filter_watch_files proc~compute_watch_files_from_settings->proc~filter_watch_files proc~gather_files_with_mask gather_files_with_mask proc~compute_watch_files_from_settings->proc~gather_files_with_mask proc~is_run_or_test is_run_or_test proc~compute_watch_files_from_settings->proc~is_run_or_test proc~normalize_path normalize_path proc~compute_watch_files_from_settings->proc~normalize_path proc~push_file_with_mask push_file_with_mask proc~compute_watch_files_from_settings->proc~push_file_with_mask proc~select_names_or_all select_names_or_all proc~compute_watch_files_from_settings->proc~select_names_or_all proc~trim_or_empty trim_or_empty proc~compute_watch_files_from_settings->proc~trim_or_empty targets_from_sources targets_from_sources proc~compute_watch_files_from_settings->targets_from_sources proc~file_fingerprint file_fingerprint proc~init_fingerprints->proc~file_fingerprint colorize colorize proc~log_info->colorize proc~log_warn->colorize proc~manifest_key_from_files->basename features features proc~manifest_key_from_files->features proc~manifest_key_from_files->proc~file_fingerprint proc~fnv1a_mix_i64 fnv1a_mix_i64 proc~manifest_key_from_files->proc~fnv1a_mix_i64 proc~fnv1a_mix_str fnv1a_mix_str proc~manifest_key_from_files->proc~fnv1a_mix_str proc~feat_after_noop watch_feature_t%feat_after_noop proc~on_after_run_all->proc~feat_after_noop proc~feat_before_noop watch_feature_t%feat_before_noop proc~on_before_run_all->proc~feat_before_noop proc~feat_list_noop watch_feature_t%feat_list_noop proc~on_watch_list_built_all->proc~feat_list_noop proc~print_banner->proc~ftoa proc~print_banner->str proc~print_banner->colorize proc~active_features active_features proc~print_banner->proc~active_features proc~active_profile active_profile proc~print_banner->proc~active_profile proc~command_mode command_mode proc~print_banner->proc~command_mode proc~trim_or_default trim_or_default proc~print_banner->proc~trim_or_default proc~print_file_list->str proc~print_file_list->colorize proc~run_command_and_report->proc~ftoa proc~run_command_and_report->str proc~run_command_and_report->colorize run run proc~run_command_and_report->run proc~join_csv join_csv proc~active_features->proc~join_csv proc~active_profile->proc~trim_or_default proc~dfs_mark_bool->proc~dfs_mark_bool dependencies dependencies proc~dfs_mark_bool->dependencies proc~find_ptr_index find_ptr_index proc~dfs_mark_bool->proc~find_ptr_index proc~dfs_mark_mask->proc~dfs_mark_mask proc~dfs_mark_mask->dependencies proc~dfs_mark_mask->proc~find_ptr_index proc~hash_block hash_block proc~file_fingerprint->proc~hash_block proc~filter_watch_files->basename proc~filter_watch_files->proc~normalize_path glob glob proc~filter_watch_files->glob proc~fnv1a_mix_str->proc~fnv1a_mix_i64 include_dependencies include_dependencies proc~gather_files_with_mask->include_dependencies proc~vec_push_unique vec_push_unique proc~gather_files_with_mask->proc~vec_push_unique proc~push_file_with_mask->proc~vec_push_unique proc~select_names_or_all->basename proc~select_names_or_all->is_executable_target proc~select_names_or_all->glob proc~hash_block->proc~fnv1a_mix_i64 proc~vec_push_unique->proc~normalize_path exists exists proc~vec_push_unique->exists proc~is_ignored_path is_ignored_path proc~vec_push_unique->proc~is_ignored_path proc~is_in_dep_dirs is_in_dep_dirs proc~vec_push_unique->proc~is_in_dep_dirs proc~vec_grow vec_grow proc~vec_push_unique->proc~vec_grow proc~is_ignored_path->proc~normalize_path proc~contains_path_fragment contains_path_fragment proc~is_ignored_path->proc~contains_path_fragment proc~starts_with starts_with proc~is_ignored_path->proc~starts_with proc~is_in_dep_dirs->proc~normalize_path proc~is_in_dep_dirs->proc~starts_with proc~ends_with ends_with proc~contains_path_fragment->proc~ends_with

Source Code

   subroutine watcher_init(self, cfg)
      class(watcher_t), intent(inout) :: self
      type(watch_config_t), intent(in) :: cfg

      self%cfg = cfg
      call set_low_cpu(self%cfg%w%low_cpu)

      call enable_features(self%fm, self%cfg%w)
      call self%fm%init_all(self%cfg)
      call self%fm%on_start_all()

      call rebuild_watch_list(self, print_header=.true.)

      if (self%cfg%w%run_on_start) then
         call run_once(self, trim(self%cfg%fpm_cmdline))
      end if
   end subroutine watcher_init