Electroneum
Loading...
Searching...
No Matches
epee::math_helper::once_a_time< scale, default_interval, start_immediate > Class Template Reference

#include <math_helper.h>

Public Member Functions

 once_a_time ()
template<class functor_t>
bool do_call (functor_t functr)

Detailed Description

template<uint64_t scale, int default_interval, bool start_immediate = true>
class epee::math_helper::once_a_time< scale, default_interval, start_immediate >

Definition at line 234 of file math_helper.h.

Constructor & Destructor Documentation

◆ once_a_time()

template<uint64_t scale, int default_interval, bool start_immediate = true>
epee::math_helper::once_a_time< scale, default_interval, start_immediate >::once_a_time ( )
inline

Definition at line 255 of file math_helper.h.

255 :m_interval(default_interval * scale)
256 {
257 m_last_worked_time = 0;
258 if(!start_immediate)
259 m_last_worked_time = get_time();
260 }

Member Function Documentation

◆ do_call()

template<uint64_t scale, int default_interval, bool start_immediate = true>
template<class functor_t>
bool epee::math_helper::once_a_time< scale, default_interval, start_immediate >::do_call ( functor_t functr)
inline

Definition at line 263 of file math_helper.h.

264 {
265 uint64_t current_time = get_time();
266
267 if(current_time - m_last_worked_time > m_interval)
268 {
269 bool res = functr();
270 m_last_worked_time = get_time();
271 return res;
272 }
273 return true;
274 }

The documentation for this class was generated from the following file:
  • /home/abuild/rpmbuild/BUILD/electroneum-5.1.3.1-build/electroneum-5.1.3.1/contrib/epee/include/math_helper.h