46 #ifndef TIMER_MONITOR_H    47 #define TIMER_MONITOR_H    49 #if (defined(__APPLE__) && defined(__MACH__)) || defined(__OpenBSD__)    50   #define USE_KQUEUE_TIMER    52   #include <sys/event.h>    53   #include <sys/types.h>    55   #define USE_POSIX_TIMER    63 #include "final/eventloop/monitor.h"    64 #include "final/eventloop/pipedata.h"    65 #include "final/ftypes.h"    71 class SigAlrmHandlerInstaller;
    72 struct KqueueHandlerInstaller;
    81     using Monitor::Monitor;
    87     virtual void setInterval ( std::chrono::nanoseconds
    88                              , std::chrono::nanoseconds ) = 0;
    99     using TimerMonitorImpl::TimerMonitorImpl;
   120     template <
typename T>
   121     void init (handler_t, T&&);
   122     void setInterval ( std::chrono::nanoseconds
   123                      , std::chrono::nanoseconds ) 
override;
   124     void trigger(
short) 
override;
   128     void createAlarmPipe();
   131 #if defined(USE_POSIX_TIMER)   134     PipeData alarm_pipe{NO_FILE_DESCRIPTOR, NO_FILE_DESCRIPTOR};
   136 #endif  // defined(USE_POSIX_TIMER)   139 #if defined(USE_POSIX_TIMER)   141 template <
typename T>
   142 inline void PosixTimer::init (handler_t hdl, T&& uc)
   144   if ( isInitialized() )
   145     throw monitor_error{
"This instance has already been initialised."};
   147   setHandler (std::move(hdl));
   148   setUserContext (std::forward<T>(uc));
   151 #endif  // defined(USE_POSIX_TIMER)   162     using TimerMonitorImpl::TimerMonitorImpl;
   183     template <
typename T>
   184     void init (handler_t, T&&);
   185     void setInterval ( std::chrono::nanoseconds
   186                      , std::chrono::nanoseconds ) 
override;
   187     void trigger(
short) 
override;
   192 #if defined(USE_KQUEUE_TIMER) || defined(UNIT_TEST)   200     static constexpr 
int NO_TIMER_ID{-1};
   203     int       timer_id{NO_TIMER_ID};
   204     bool      first_interval{
true};
   205     TimerSpec timer_spec{};
   206     handler_t timer_handler{};
   207     static KqueueHandlerInstaller* kqueue_handler_installer;
   210     friend class KqueueHandler;
   211 #endif  // defined(USE_KQUEUE_TIMER)   214 #if defined(USE_KQUEUE_TIMER) || defined(UNIT_TEST)   216 template <
typename T>
   217 inline void KqueueTimer::init (handler_t hdl, T&& uc)
   219   if ( isInitialized() )
   220     throw monitor_error{
"This instance has already been initialised."};
   222   timer_handler = std::move(hdl);
   223   setUserContext (std::forward<T>(uc));
   226 #endif  // defined(USE_KQUEUE_TIMER)   235   #if defined(__APPLE__) && defined(__MACH__)   237   #elif defined(__OpenBSD__)   254     using base_class::base_class;
   274     auto getClassName() 
const -> 
FString override;
   279 inline auto TimerMonitor::getClassName() 
const -> 
FString   280 { 
return "TimerMonitor"; }
   284 #endif  // TIMER_MONITOR_H Definition: timer_monitor.h:249
 
Definition: eventloop.h:48
 
Definition: class_template.cpp:25
 
Definition: timer_monitor.h:77
 
Definition: posix_timer.cpp:169
 
Definition: timer_monitor.h:95
 
Definition: timer_monitor.h:158
 
Definition: pipedata.h:47
 
Definition: timer_monitor.h:233