anchor.diff:      code_change/3]).
   
   -define(TIMEOUT, timer:minutes(5)).
  --define(DEFAULT_DELAY, onepanel_env:get(services_check_delay)).
  +
  +%% Frequency of checks
   -define(TICK_PERIOD, timer:seconds(10)).
   
   -type condition() :: fun(() -> boolean()).
  
positive.code:     gen_server:start_link({local, ?ONEPANEL_CRON_NAME}, ?MODULE, [], []).
  
  
  -spec register(JobName :: job_name(), Action :: action(),
      Period :: non_neg_integer()) -> ok.
  register(JobName, Action, Period) ->
      register(JobName, Action, Period, fun() -> true end).
  
  
  -spec register(JobName :: job_name(), Action :: action(),
      Period :: non_neg_integer(), Condition :: condition()) -> ok.
  register(JobName, Action, Period, Condition) ->
  
negative.code:     condition :: condition(),
      action :: action(),
  
      %% Period in milliseconds to pass between job runs
      period :: non_neg_integer(),
  
      %% Millisecond timestamp of the last attempt to run the job,
      %% including times when the 'condition' was not met.
      last_run = 0 :: non_neg_integer(),
  
      % pid of the last invocation
      pid :: pid() | undefined
  }).
  
  -type job_name() :: atom().
  -type job() :: #job{}.
  
  -type state() :: #{job_name() => job()}.
  
  -export_type([condition/0, action/0, job/0, job_name/0]).
  
  