definitions.hpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // SPDX-License-Identifier: MIT
  2. // SPDX-FileCopyrightText: 2022 Ivan Baidakou
  3. #pragma once
  4. #include <cstddef>
  5. #include <cstdint>
  6. #include <limits>
  7. namespace rotor_light {
  8. /** \brief actor states */
  9. enum class State { off, initializing, initialized, operational, shutting_down };
  10. namespace details {
  11. enum class StateCommand { init, start, shutdown };
  12. }
  13. // clang-format off
  14. /** \brief actor fail policy
  15. *
  16. * It defines the supervisor behavior upon actor shutdown.
  17. *
  18. */
  19. enum class FailPolicy {
  20. restart = 0b00000001,
  21. force_restart = 0b00000011,
  22. escalate = 0b00000100,
  23. force_escalate = 0b00001100,
  24. ignore = 0b00010000,
  25. };
  26. // clang-format on
  27. using MessageTypeId = ROTOR_LIGHT_MESSAGE;
  28. using Index = ROTOR_LIGHT_INDEX;
  29. using ActorId = ROTOR_LIGHT_ACTOR;
  30. using EventId = ROTOR_LIGHT_EVENT;
  31. static constexpr size_t default_queue = ROTOR_LIGHT_FW_QUEUE;
  32. static constexpr auto broadcast = std::numeric_limits<ActorId>::max();
  33. using TimePoint = ROTOR_LIGHT_TIMEPOINT;
  34. using Duration = ROTOR_LIGHT_DURATION;
  35. using NowFunction = TimePoint (*)();
  36. using Callback = void (*)(void *);
  37. namespace ctx {
  38. struct thread {};
  39. struct interrupt {};
  40. } // namespace ctx
  41. } // namespace rotor_light