CUBRID Engine  latest
cubthread::looper Class Reference

#include <thread_looper.hpp>

Collaboration diagram for cubthread::looper:
Collaboration graph

Public Member Functions

 looper ()
 
 looper (const looper &other)
 
 looper (const period_function &setup_period_function)
 
 looper (const delta_time &fixed_period)
 
template<std::size_t Count>
 looper (const std::array< delta_time, Count > periods)
 
 ~looper (void)
 
void put_to_sleep (waiter &waiter_arg)
 
void reset (void)
 
bool stop (void)
 
bool is_stopped (void) const
 
bool was_woken_up (void) const
 
void get_stats (cubperf::stat_value *stats_out)
 

Static Public Member Functions

static std::size_t get_stats_value_count (void)
 
static const char * get_stat_name (std::size_t stat_index)
 

Private Types

enum  wait_type { INF_WAITS, FIXED_WAITS, INCREASING_WAITS, CUSTOM_WAITS }
 

Private Member Functions

void setup_fixed_waits (bool &is_timed_wait, delta_time &period)
 
void setup_infinite_wait (bool &is_timed_wait, delta_time &period)
 
void setup_increasing_waits (bool &is_timed_wait, delta_time &period)
 

Private Attributes

std::size_t m_periods_count
 
delta_time m_periods [MAX_LOOPER_PERIODS]
 
std::atomic< std::size_t > m_period_index
 
std::atomic< boolm_stop
 
std::atomic< boolm_was_woken_up
 
period_function m_setup_period
 
std::chrono::system_clock::time_point m_start_execution_time
 
cubperf::statsetm_stats
 
wait_type m_wait_type
 

Detailed Description

Definition at line 81 of file thread_looper.hpp.

Member Enumeration Documentation

Enumerator
INF_WAITS 
FIXED_WAITS 
INCREASING_WAITS 
CUSTOM_WAITS 

Definition at line 132 of file thread_looper.hpp.

Constructor & Destructor Documentation

cubthread::looper::looper ( )

Definition at line 47 of file thread_looper.cpp.

References m_setup_period, and setup_infinite_wait().

cubthread::looper::looper ( const period_function setup_period_function)

Definition at line 95 of file thread_looper.cpp.

References CUSTOM_WAITS, m_setup_period, and m_wait_type.

cubthread::looper::looper ( const delta_time fixed_period)

Definition at line 102 of file thread_looper.cpp.

References FIXED_WAITS, m_periods, m_setup_period, m_wait_type, and setup_fixed_waits().

template<std::size_t Count>
cubthread::looper::looper ( const std::array< delta_time, Count >  periods)
cubthread::looper::~looper ( void  )

Definition at line 111 of file thread_looper.cpp.

References m_stats.

Member Function Documentation

const char * cubthread::looper::get_stat_name ( std::size_t  stat_index)
static

Definition at line 237 of file thread_looper.cpp.

References cubperf::statset_definition::get_value_name().

Referenced by cubthread::daemon::get_stat_name().

Here is the caller graph for this function:

void cubthread::looper::get_stats ( cubperf::stat_value stats_out)

Definition at line 225 of file thread_looper.cpp.

References cubperf::statset_definition::get_stat_values_with_converted_timers(), and m_stats.

Referenced by cubthread::daemon::get_stats().

Here is the caller graph for this function:

std::size_t cubthread::looper::get_stats_value_count ( void  )
static
bool cubthread::looper::is_stopped ( void  ) const

Definition at line 177 of file thread_looper.cpp.

References m_stop.

Referenced by cubthread::daemon::loop_with_context(), cubthread::daemon::loop_without_context(), and put_to_sleep().

Here is the caller graph for this function:

void cubthread::looper::reset ( void  )

Definition at line 164 of file thread_looper.cpp.

References cubperf::statset_definition::increment(), m_period_index, and m_stats.

Referenced by cubthread::daemon::reset_looper(), and setup_increasing_waits().

Here is the caller graph for this function:

void cubthread::looper::setup_fixed_waits ( bool is_timed_wait,
delta_time period 
)
private

Definition at line 189 of file thread_looper.cpp.

References assert, m_period_index, and m_periods.

Referenced by looper().

Here is the caller graph for this function:

void cubthread::looper::setup_increasing_waits ( bool is_timed_wait,
delta_time period 
)
private

Definition at line 206 of file thread_looper.cpp.

References m_period_index, m_periods, m_periods_count, m_was_woken_up, and reset().

Referenced by looper().

Here is the caller graph for this function:

void cubthread::looper::setup_infinite_wait ( bool is_timed_wait,
delta_time period 
)
private

Definition at line 198 of file thread_looper.cpp.

References assert, and m_period_index.

Referenced by looper().

Here is the caller graph for this function:

bool cubthread::looper::stop ( void  )

Definition at line 171 of file thread_looper.cpp.

References m_stop.

Referenced by cubthread::daemon::stop_execution().

Here is the caller graph for this function:

bool cubthread::looper::was_woken_up ( void  ) const

Definition at line 183 of file thread_looper.cpp.

References m_was_woken_up.

Referenced by cubthread::daemon::was_woken_up().

Here is the caller graph for this function:

Member Data Documentation

std::atomic<std::size_t> cubthread::looper::m_period_index
private
delta_time cubthread::looper::m_periods[MAX_LOOPER_PERIODS]
private

Definition at line 145 of file thread_looper.hpp.

Referenced by looper(), setup_fixed_waits(), and setup_increasing_waits().

std::size_t cubthread::looper::m_periods_count
private

Definition at line 144 of file thread_looper.hpp.

Referenced by looper(), and setup_increasing_waits().

period_function cubthread::looper::m_setup_period
private

Definition at line 151 of file thread_looper.hpp.

Referenced by looper(), and put_to_sleep().

std::chrono::system_clock::time_point cubthread::looper::m_start_execution_time
private

Definition at line 155 of file thread_looper.hpp.

Referenced by looper(), and put_to_sleep().

cubperf::statset& cubthread::looper::m_stats
private

Definition at line 158 of file thread_looper.hpp.

Referenced by get_stats(), put_to_sleep(), reset(), and ~looper().

std::atomic<bool> cubthread::looper::m_stop
private

Definition at line 148 of file thread_looper.hpp.

Referenced by is_stopped(), and stop().

wait_type cubthread::looper::m_wait_type
private

Definition at line 161 of file thread_looper.hpp.

Referenced by looper().

std::atomic<bool> cubthread::looper::m_was_woken_up
private

Definition at line 149 of file thread_looper.hpp.

Referenced by put_to_sleep(), setup_increasing_waits(), and was_woken_up().


The documentation for this class was generated from the following files: