OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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 97 of file QueryState.h.

Constructor & Destructor Documentation

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

Definition at line 43 of file QueryState.cpp.

44  : name(name)
45  , parent(parent)
46  , thread_id(std::this_thread::get_id())
47  , started(Clock::now().time_since_epoch())
48  , stopped(Clock::duration::zero()) {}
Clock::duration const started
Definition: QueryState.h:101
Events::iterator const parent
Definition: QueryState.h:99
std::atomic< Clock::duration > stopped
Definition: QueryState.h:103
std::thread::id const thread_id
Definition: QueryState.h:100
char const *const name
Definition: QueryState.h:98

Member Function Documentation

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

Definition at line 106 of file QueryState.h.

References started, and stopped.

106  {
107  auto const stop_time = stopped.load();
108  return boost::make_optional(
109  stop_time != Clock::duration::zero(),
110  std::chrono::duration_cast<Units>(stop_time - started).count());
111  }
Clock::duration const started
Definition: QueryState.h:101
std::atomic< Clock::duration > stopped
Definition: QueryState.h:103
void query_state::Event::stop ( )

Definition at line 50 of file QueryState.cpp.

References CHECK, and stopped.

50  {
51  CHECK(stopped.exchange(Clock::now().time_since_epoch()) == Clock::duration::zero())
52  << "stop() called more than once.";
53 }
std::atomic< Clock::duration > stopped
Definition: QueryState.h:103
#define CHECK(condition)
Definition: Logger.h:291

Member Data Documentation

char const* const query_state::Event::name

Definition at line 98 of file QueryState.h.

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

Definition at line 99 of file QueryState.h.

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

Definition at line 101 of file QueryState.h.

Referenced by duration().

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

Definition at line 103 of file QueryState.h.

Referenced by duration(), and stop().

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

Definition at line 100 of file QueryState.h.


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