anchor.diff:                          last_status_time }).
   
   -define(STATUS_INTERVAL, 10000).                % Milliseconds between status callbacks
  +-define(WORKER_TIMEOUT, 2000).
   
   %% ===================================================================
   %% API functions
  
positive.code: 
      %% Spawn a bunch of workers
      Self = self(),
      [spawn_link(fun() -> index_worker_loop0(Self, Index) end) || _ <- lists:seq(1,Workers)],
  
      %% Initialize status and start processing files
      Status = #index_status {total_files = TotalFiles,
                              total_bytes = TotalBytes,
                              start_time  = now(),
                              last_status_time = now()},
      index_master_loop(list_dir(Dir), Status, StatusFn).
  
  
  
  index_master_loop([], Status, StatusFn) ->
      StatusFn(Status),
      ok;
  index_master_loop([FName | Rest], Status, StatusFn) ->
      TimeSinceUpdate = timer:now_diff(now(), Status#index_status.last_status_time) / 1000,
      NewStatus = case TimeSinceUpdate > ?STATUS_INTERVAL of
  
negative.code:                     error_logger:error_msg("Failed to read file ~p: ~p\n", [FName, Reason]),
                      QueuePid ! {next_file, self(), 0}
              end,
              index_worker_loop(QueuePid, Client, AnalyzerPid, IndexFsmPid, Index, DefaultField);
          stop ->
              stop
      after ?WORKER_TIMEOUT ->
              stop
      end.
  