| 
    Diag-Client-Lib
    
   | 
 
Timer class for timeout monitoring. More...
#include <sync_timer.h>
Public Types | |
| enum class | TimerState : std::uint8_t { kIdle = 0 , kCancelRequested , kTimeout } | 
| Definition of different timer state during timeout monitoring.  More... | |
| using | Clock = ClockType | 
| Type alias for the clock type.  More... | |
| using | TimePoint = std::chrono::time_point< Clock > | 
| Type alias for the clock time point.  More... | |
Public Member Functions | |
| SyncTimer () | |
| Construct an instance of SyncTimer.  More... | |
| ~SyncTimer () | |
| Destruct an instance of SyncTimer.  More... | |
| template<typename TimeoutCallback , typename CancelCallback > | |
| void | WaitForTimeout (TimeoutCallback &&timeout_func, CancelCallback &&cancellation_func, std::chrono::milliseconds const timeout) | 
| Helper function to wait for response with timeout monitoring.  More... | |
| auto | IsTimerActive () | 
| Function to query if timer is running.  More... | |
| void | CancelWait () | 
| Function to cancel the synchronous wait.  More... | |
Private Member Functions | |
| auto | Start (std::chrono::milliseconds const timeout) noexcept -> TimerState | 
| Function to start the timeout monitoring.  More... | |
| void | Stop () noexcept | 
| Function to stop the current timeout monitoring.  More... | |
Private Attributes | |
| std::condition_variable | cond_var_ | 
| The conditional variable needed for synchronizing between start and stop of running timer.  More... | |
| std::mutex | mutex_lock_ | 
| The mutex for the conditional variable.  More... | |
| bool | exit_request_ | 
| The flag to terminate the wait.  More... | |
| bool | start_running_ | 
| The flag to stop the current running timer.  More... | |
Timer class for timeout monitoring.
| ClockType | The type of clock to be used for time monitoring | 
Definition at line 25 of file sync_timer.h.
| using utility::sync_timer::SyncTimer< ClockType >::Clock = ClockType | 
Type alias for the clock type.
Definition at line 30 of file sync_timer.h.
| using utility::sync_timer::SyncTimer< ClockType >::TimePoint = std::chrono::time_point<Clock> | 
Type alias for the clock time point.
Definition at line 35 of file sync_timer.h.
      
  | 
  strong | 
Definition of different timer state during timeout monitoring.
| Enumerator | |
|---|---|
| kIdle | |
| kCancelRequested | |
| kTimeout | |
Definition at line 40 of file sync_timer.h.
      
  | 
  inline | 
Construct an instance of SyncTimer.
Definition at line 45 of file sync_timer.h.
      
  | 
  inline | 
Destruct an instance of SyncTimer.
Definition at line 50 of file sync_timer.h.
References utility::sync_timer::SyncTimer< ClockType >::cond_var_, utility::sync_timer::SyncTimer< ClockType >::exit_request_, utility::sync_timer::SyncTimer< ClockType >::mutex_lock_, and utility::sync_timer::SyncTimer< ClockType >::start_running_.
      
  | 
  inline | 
Function to cancel the synchronous wait.
Definition at line 91 of file sync_timer.h.
References utility::sync_timer::SyncTimer< ClockType >::Stop().
Referenced by doip_client::channel::tcp_channel::DiagnosticMessageHandler::DiagnosticMessageHandlerImpl::Stop(), and doip_client::channel::tcp_channel::RoutingActivationHandler::RoutingActivationHandlerImpl::Stop().


      
  | 
  inline | 
Function to query if timer is running.
Definition at line 83 of file sync_timer.h.
References utility::sync_timer::SyncTimer< ClockType >::mutex_lock_, and utility::sync_timer::SyncTimer< ClockType >::start_running_.
Referenced by doip_client::channel::tcp_channel::DiagnosticMessageHandler::DiagnosticMessageHandlerImpl::Stop(), and doip_client::channel::tcp_channel::RoutingActivationHandler::RoutingActivationHandlerImpl::Stop().

      
  | 
  inlineprivatenoexcept | 
Function to start the timeout monitoring.
| [in] | timeout | The timeout value in milliseconds after which timeout happens | 
Definition at line 101 of file sync_timer.h.
References utility::sync_timer::SyncTimer< ClockType >::cond_var_, utility::sync_timer::SyncTimer< ClockType >::exit_request_, utility::sync_timer::SyncTimer< ClockType >::kCancelRequested, utility::sync_timer::SyncTimer< ClockType >::kIdle, utility::sync_timer::SyncTimer< ClockType >::kTimeout, utility::sync_timer::SyncTimer< ClockType >::mutex_lock_, and utility::sync_timer::SyncTimer< ClockType >::start_running_.
Referenced by utility::sync_timer::SyncTimer< ClockType >::WaitForTimeout().

      
  | 
  inlineprivatenoexcept | 
Function to stop the current timeout monitoring.
Definition at line 134 of file sync_timer.h.
Referenced by utility::sync_timer::SyncTimer< ClockType >::CancelWait().

      
  | 
  inline | 
Helper function to wait for response with timeout monitoring.
| TimeoutCallback | The callback functor type for timeout notification | 
| CancelCallback | The callback functor type for cancellation notification | 
| [in] | timeout_func | The functor to be called when timeout occurs | 
| [in] | cancel_func | The functor to be called when expected event occurs within timeout | 
| [in] | timeout | The timeout in milliseconds | 
Definition at line 71 of file sync_timer.h.
References utility::sync_timer::SyncTimer< ClockType >::kTimeout, and utility::sync_timer::SyncTimer< ClockType >::Start().

      
  | 
  private | 
The conditional variable needed for synchronizing between start and stop of running timer.
Definition at line 144 of file sync_timer.h.
Referenced by utility::sync_timer::SyncTimer< ClockType >::Start(), and utility::sync_timer::SyncTimer< ClockType >::~SyncTimer().
      
  | 
  private | 
The flag to terminate the wait.
Definition at line 154 of file sync_timer.h.
Referenced by utility::sync_timer::SyncTimer< ClockType >::Start(), and utility::sync_timer::SyncTimer< ClockType >::~SyncTimer().
      
  | 
  private | 
The mutex for the conditional variable.
Definition at line 149 of file sync_timer.h.
Referenced by utility::sync_timer::SyncTimer< ClockType >::IsTimerActive(), utility::sync_timer::SyncTimer< ClockType >::Start(), and utility::sync_timer::SyncTimer< ClockType >::~SyncTimer().
      
  | 
  private | 
The flag to stop the current running timer.
Definition at line 159 of file sync_timer.h.
Referenced by utility::sync_timer::SyncTimer< ClockType >::IsTimerActive(), utility::sync_timer::SyncTimer< ClockType >::Start(), and utility::sync_timer::SyncTimer< ClockType >::~SyncTimer().