Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
fc::mock_time_traits Class Reference

mock out fc::time_point::now() and provide a mock deadline timer More...

#include <mock_time.hpp>

Public Types

typedef source_traits::time_type time_type
 
typedef source_traits::duration_type duration_type
 

Static Public Member Functions

static time_type now () noexcept
 
static void set_now (time_type t)
 
static void set_now (const fc::time_point &now)
 
static bool is_set ()
 
static time_type add (time_type t, duration_type d)
 
static duration_type subtract (time_type t1, time_type t2)
 
static bool less_than (time_type t1, time_type t2)
 
static boost::posix_time::time_duration to_posix_duration (duration_type d)
 
static fc::time_point fc_now ()
 

Detailed Description

Definition at line 9 of file mock_time.hpp.

Member Typedef Documentation

◆ duration_type

source_traits::duration_type fc::mock_time_traits::duration_type

Definition at line 13 of file mock_time.hpp.

◆ time_type

source_traits::time_type fc::mock_time_traits::time_type

Definition at line 12 of file mock_time.hpp.

Member Function Documentation

◆ add()

static time_type fc::mock_time_traits::add ( time_type t,
duration_type d )
inlinestatic

Definition at line 25 of file mock_time.hpp.

25{ return source_traits::add( t, d ); }

◆ fc_now()

fc::time_point fc::mock_time_traits::fc_now ( )
static

Definition at line 29 of file mock_time.cpp.

29 {
30 return fc::time_point( fc::microseconds( ( mock_time_traits::now() - epoch_ ).total_microseconds() ) );
31}
static time_type now() noexcept
Definition mock_time.cpp:10
Here is the call graph for this function:
Here is the caller graph for this function:

◆ is_set()

static bool fc::mock_time_traits::is_set ( )
inlinestatic

Definition at line 23 of file mock_time.hpp.

23{ return mock_enabled_; }
Here is the caller graph for this function:

◆ less_than()

static bool fc::mock_time_traits::less_than ( time_type t1,
time_type t2 )
inlinestatic

Definition at line 27 of file mock_time.hpp.

27{ return source_traits::less_than( t1, t2 ); }

◆ now()

mock_time_traits::time_type fc::mock_time_traits::now ( )
staticnoexcept

Definition at line 10 of file mock_time.cpp.

10 {
11 return epoch_ + boost::posix_time::microseconds( now_.load() );
12}
Here is the caller graph for this function:

◆ set_now() [1/2]

void fc::mock_time_traits::set_now ( const fc::time_point & now)
static

Definition at line 19 of file mock_time.cpp.

19 {
20 now_ = now.time_since_epoch().count();
21 if( !mock_enabled_ ) mock_enabled_ = true;
22
23 // After modifying the clock, we need to sleep the thread to give the io_service
24 // the opportunity to poll and notice the change in clock time.
25 // See to_posix_duration()
26 std::this_thread::sleep_for( std::chrono::milliseconds( 2 ) );
27}
Here is the call graph for this function:

◆ set_now() [2/2]

void fc::mock_time_traits::set_now ( time_type t)
static

Definition at line 14 of file mock_time.cpp.

14 {
15 fc::time_point now( fc::microseconds( (t - epoch_).total_microseconds() ) );
16 set_now( now );
17}
static void set_now(time_type t)
Definition mock_time.cpp:14
Here is the call graph for this function:
Here is the caller graph for this function:

◆ subtract()

static duration_type fc::mock_time_traits::subtract ( time_type t1,
time_type t2 )
inlinestatic

Definition at line 26 of file mock_time.hpp.

26{ return source_traits::subtract( t1, t2 ); }

◆ to_posix_duration()

static boost::posix_time::time_duration fc::mock_time_traits::to_posix_duration ( duration_type d)
inlinestatic

Definition at line 32 of file mock_time.hpp.

32 {
33 return d < boost::posix_time::milliseconds( 1 ) ? d : boost::posix_time::milliseconds( 1 );
34 }
CK_ULONG d

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