anchor.diff:      {noreply, NewState :: term()} |
       {stop, Reason :: term(), NewState :: term()}.
   
  --callback handle_tick(TickId :: term(), TickGeneration :: non_neg_integer(), State :: term()) ->
  +-callback handle_tick(TickId :: term(), TickGeneration :: non_neg_integer(),
  +                      State :: term()) ->
       {noreply, NewState :: term()}.
   
   -callback terminate(Reason :: (normal | shutdown | {shutdown, term()} |
  
positive.code:         -> {ok, State :: term(), Timeout :: non_neg_integer()} |
             {stop, Reason :: term()} | ignore.
  init({Mod, Args, TickOptions}) ->
      NowUS = now_timestamp_us(),
      TickSettings = proplists:get_value(ticks, TickOptions, []),
      Ticks = lists:map(
                fun ({TickId, TickDurationMS}) ->
                        #tick{id = TickId,
                              duration_us = TickDurationMS * 1000,
                              deadline_us = NowUS,
                              generation = 0}
                end,
                TickSettings),
  
negative.code: %% ------------------------------------------------------------------
  -spec handle_timeouts(State :: term()) -> {noreply, NewState :: term()}.
  handle_timeouts(State) ->
      NowNS = now_timestamp_ns(),
      Mod = get(?PROCDIC_MODULE),
      Ticks = get(?PROCDIC_TICKS),
      SortedTicks = lists:keysort(#tick.deadline_ns, Ticks),
      {NewState, NewTicks} = handle_tick_deadlines(State, SortedTicks, NowNS, Mod, []),
      _ = put(?PROCDIC_TICKS, NewTicks),
      {noreply, NewState}.
  
  
  -spec handle_tick_deadlines(State :: term(), UntriggeredTicks :: [tick()], NowNS :: timestamp(),
                              Mod :: module(), TriggeredTicks :: [tick()])
          -> {NewState :: term(), NewTicks :: [tick()]}.
  handle_tick_deadlines(State, [#tick{ deadline_ns=DeadlineNS }=Tick | UntriggeredTicks],
                        NowNS, Mod, TriggeredTicks)
    when DeadlineNS =< NowNS ->
      #tick{id = Id,
            duration_ns = DurationNS,
            generation = Generation}=Tick,
      {noreply, NewState} = Mod:handle_tick(Id, Generation, State),
      NewTick = Tick#tick{deadline_ns = DeadlineNS + DurationNS,
                          generation = Generation + 1},
      handle_tick_deadlines(NewState, UntriggeredTicks, NowNS, Mod, [NewTick | TriggeredTicks]);
  handle_tick_deadlines(State, UntriggeredTicks, _NowNS, _Mod, TriggeredTicks) ->
      {State, TriggeredTicks ++ UntriggeredTicks}.
  
  -spec inject_init_timeout({ok, State :: term()} |
  