No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 

73 líneas
1.7 KiB

  1. #pragma once
  2. #include <set>
  3. #include <memory>
  4. #include <cppcore/synchronization/locked.h>
  5. #include "impl/timer_base.h"
  6. #include "impl/registration.h"
  7. namespace asyncpp {
  8. namespace timing {
  9. namespace __impl
  10. {
  11. template<typename T_inner>
  12. struct storage
  13. {
  14. using inner_type = T_inner;
  15. inner_type inner;
  16. template<typename... X_args>
  17. inline storage(X_args&&... p_args);
  18. };
  19. }
  20. template<typename T_inner = void>
  21. struct timer
  22. : public __impl::timer_base
  23. {
  24. public:
  25. using inner_type = T_inner;
  26. using storage_type = __impl::storage<inner_type>;
  27. private:
  28. storage_type _storage;
  29. public:
  30. /**
  31. * @brief Constructor.
  32. */
  33. template<typename... X_args>
  34. inline timer(X_args&&... p_args);
  35. /**
  36. * @brief Handle idle of the runtime.
  37. *
  38. * This method is called as soon as the runtime has nothing to do.
  39. * The passed deadline is the timepoint the method should return (or null if not set).
  40. */
  41. inline void idle(const asyncpp::time_point * p_deadline);
  42. private:
  43. /**
  44. * @brief Call the idle method of the inner runtime.
  45. */
  46. template<typename X = inner_type>
  47. inline auto inner_idle(const asyncpp::time_point * p_deadline)
  48. -> std::enable_if_t<std::is_same_v<X, void>>;
  49. /**
  50. * @brief Call the idle method of the inner runtime.
  51. */
  52. template<typename X = inner_type>
  53. inline auto inner_idle(const asyncpp::time_point * p_deadline)
  54. -> std::enable_if_t<!std::is_same_v<X, void>>;
  55. };
  56. } }