1#ifndef INITIAL_WAIT_STATE_H
2#define INITIAL_WAIT_STATE_H
7#include "./timer_set_state.h"
35 std::default_random_engine _generator;
36 std::uniform_int_distribution<int> _distribution(
38 int _randomDely = _distribution(_generator);
42 auto _delay = std::chrono::milliseconds(_randomDely);
43 bool _interrupted = this->
WaitFor(_delay);
64 std::function<
void()> onTimerExpired,
66 int initialDelayMax) : helper::
MachineState<T>(currentState),
71 if ((initialDelayMin < 0) ||
72 (initialDelayMax < 0) ||
73 (initialDelayMin > initialDelayMax))
75 throw std::invalid_argument(
"Invalid initial delay minimum and/or maximum.");
MachineState(T state) noexcept
Constructor.
Definition: machine_state.h:70
Server's or client's service initial wait state.
Definition: initial_wait_state.h:24
InitialWaitState(T currentState, T nextState, T stoppedState, std::function< void()> onTimerExpired, int initialDelayMin, int initialDelayMax)
Constructor.
Definition: initial_wait_state.h:60
virtual void SetTimer() override
Set the phase time on state activation.
Definition: initial_wait_state.h:32
const int InitialDelayMin
Initial delay lower bound in milliseconds.
Definition: initial_wait_state.h:27
const int InitialDelayMax
Initial delay higher bound in milliseconds.
Definition: initial_wait_state.h:30
Server's or client's service timer set state.
Definition: timer_set_state.h:24
bool WaitFor(std::chrono::milliseconds duration)
Wait for certian period of time.
Definition: timer_set_state.h:49
const std::function< void()> OnTimerExpired
Delegate which is invoked by timer's thread when the timer is expired.
Definition: timer_set_state.h:76