OmniSciDB  49c0524acb
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
query_state::Event Struct Reference

#include <QueryState.h>

Public Member Functions

 Event (char const *const name, Events::iterator parent)
 
template<typename Units = std::chrono::milliseconds>
boost::optional< typename
Units::rep > 
duration () const
 
void stop ()
 

Public Attributes

char const *const name
 
Events::iterator const parent
 
std::thread::id const thread_id
 
Clock::duration const started
 
std::atomic< Clock::duration > stopped
 

Detailed Description

Definition at line 86 of file QueryState.h.

Constructor & Destructor Documentation

query_state::Event::Event ( char const *const  name,
Events::iterator  parent 
)

Definition at line 32 of file QueryState.cpp.

33  : name(name)
34  , parent(parent)
35  , thread_id(std::this_thread::get_id())
36  , started(Clock::now().time_since_epoch())
37  , stopped(Clock::duration::zero()) {}
Clock::duration const started
Definition: QueryState.h:90
Events::iterator const parent
Definition: QueryState.h:88
std::atomic< Clock::duration > stopped
Definition: QueryState.h:92
std::thread::id const thread_id
Definition: QueryState.h:89
char const *const name
Definition: QueryState.h:87

Member Function Documentation

template<typename Units = std::chrono::milliseconds>
boost::optional<typename Units::rep> query_state::Event::duration ( ) const
inline

Definition at line 95 of file QueryState.h.

References started, and stopped.

95  {
96  auto const stop_time = stopped.load();
97  return boost::make_optional(
98  stop_time != Clock::duration::zero(),
99  std::chrono::duration_cast<Units>(stop_time - started).count());
100  }
Clock::duration const started
Definition: QueryState.h:90
std::atomic< Clock::duration > stopped
Definition: QueryState.h:92
void query_state::Event::stop ( )

Definition at line 39 of file QueryState.cpp.

References CHECK, and stopped.

39  {
40  CHECK(stopped.exchange(Clock::now().time_since_epoch()) == Clock::duration::zero())
41  << "stop() called more than once.";
42 }
std::atomic< Clock::duration > stopped
Definition: QueryState.h:92
#define CHECK(condition)
Definition: Logger.h:187

Member Data Documentation

char const* const query_state::Event::name

Definition at line 87 of file QueryState.h.

Events::iterator const query_state::Event::parent

Definition at line 88 of file QueryState.h.

Clock::duration const query_state::Event::started

Definition at line 90 of file QueryState.h.

Referenced by duration().

std::atomic<Clock::duration> query_state::Event::stopped

Definition at line 92 of file QueryState.h.

Referenced by duration(), and stop().

std::thread::id const query_state::Event::thread_id

Definition at line 89 of file QueryState.h.


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