anchor.diff:                  n :: integer(),
                   interval = 0 :: non_neg_integer(),  %%ms
                   delay_between_executions = 0 :: non_neg_integer(),  %%ms
  +                tref :: timer:tref() | undefined,
                   schedule = [] :: [pid()],
                   schedule_reversed = [] :: [pid()]}).
   
  
positive.code: 
  merge_state(#state{interval = I, delay_between_executions = D, n = N, max_n = MaxN},
              #state{n = OldN, max_n = OldMaxN} = OldState) ->
      NewN = N - (OldMaxN - OldN),
      OldState#state{interval = I, delay_between_executions = D, n = NewN, max_n = MaxN}.
  
  maybe_run_fn(#state{schedule = [], schedule_reversed = []} = State) ->
      State;
  
negative.code: handle_continue(maybe_run_fn, State) ->
      NewState = maybe_run_fn(State),
      {noreply, NewState, timeout(NewState)}.
  
  format_status(_Opt, [_PDict, State]) ->
      ScheduleLen=length(State#state.schedule),
      ScheduleRevLen=length(State#state.schedule_reversed),
      State1=setelement(#state.schedule,State,ScheduleLen),
      setelement(#state.schedule_reversed,State1,ScheduleRevLen).
  %%------------------------------------------------------------------------------
  %% internal functions
  %%------------------------------------------------------------------------------
  