dxd - dynax driver framework 3.0.2
cross platform open source driver development framework
Loading...
Searching...
No Matches
dx::clock< source_t > Class Template Referenceabstract

realtime tick mechanism: one thread per clock - run/halt lifecycle and tick dispatch; the source_t base owns objective and wait More...

#include <dx_clock.h>

Inheritance diagram for dx::clock< source_t >:
Collaboration diagram for dx::clock< source_t >:

Public Types

typedef source_t::clock_t clock_t
typedef source_t::event_t event_t

Public Member Functions

 clock()= default
template<typename... args_t>
 clock(args_t&&... args)
virtual void halt() noexcept
 stop and remove clock thread
void initialize(const typename clock_t::duration& duration)
 operator event_t&() noexcept
 operator event_t*() noexcept
virtual void run()
 create and start clock thread
virtual void sync(const typename clock_t::time_point& now)
virtual void tick()= 0
virtual source& wait(bool reset= false)
virtual ~clock()

Protected Member Functions

virtual void discharge() noexcept
 the thread's last act: releases what its ticks charged - an OS may tie such a resource to the thread that created it
realtime& initialize(const std::chrono::high_resolution_clock::duration& resolution)
virtual void notify() noexcept
bool self() const
 the caller is the clock's own thread: a halt from its tick ends the loop, nobody joins it

Protected Attributes

std::condition_variable condition_variable
_event_t event
std::mutex mutex
_clock_t::time_point objective
std::atomic<bool> running{false}
os_result status{not_initialized}

Detailed Description

template<typename source_t = source<>>
class dx::clock< source_t >

realtime tick mechanism: one thread per clock - run/halt lifecycle and tick dispatch; the source_t base owns objective and wait

Member Typedef Documentation

◆ clock_t

template<typename source_t= source<>>
typedef source_t::clock_t dx::clock<source_t>::clock_t

◆ event_t

template<typename source_t= source<>>
typedef source_t::event_t dx::clock<source_t>::event_t

Constructor & Destructor Documentation

◆ clock() [1/2]

template<typename source_t= source<>>
dx::clock<source_t>::clock()
default

◆ clock() [2/2]

template<typename source_t= source<>>
template<typename... args_t>
dx::clock<source_t>::clock(args_t&&... args)
inline

◆ ~clock()

template<typename source_t= source<>>
virtual dx::clock<source_t>::~clock()
inlinevirtual

Member Function Documentation

◆ discharge()

template<typename source_t= source<>>
virtual void dx::clock<source_t>::discharge()
inlineprotectedvirtualnoexcept

the thread's last act: releases what its ticks charged - an OS may tie such a resource to the thread that created it

Reimplemented in dx::stream::group< _device_t, source_t >, dx::stream::group< device_t, dx::source<> >, and dx::stream::group< device_t, source_t >.

◆ halt()

template<typename source_t= source<>>
virtual void dx::clock<source_t>::halt()
inlinevirtualnoexcept

stop and remove clock thread

<halting from its own tick: the loop ends once the tick returns, nobody can join here

<elect the single caller allowed to join() - concurrent halt() callers (e.g. async surprise vs. the main test thread) would otherwise both reach join() on the same thread, undefined behavior

Here is the caller graph for this function:

◆ initialize() [1/2]

template<typename source_t= source<>>
void dx::clock<source_t>::initialize(const typename clock_t::duration& duration)
inline
Here is the caller graph for this function:

◆ initialize() [2/2]

realtime& dx::thread::prio::realtime::initialize(const std::chrono::high_resolution_clock::duration& resolution)
inlineinherited
Todo
dx::thread::prio: replace experimental hardcoded preemption limit with real limit obtained from machine
Here is the call graph for this function:
Here is the caller graph for this function:

◆ notify()

template<typename source_t= source<>>
virtual void dx::clock<source_t>::notify()
inlineprotectedvirtualnoexcept

notify change from device requiring streaming reset

◆ operator event_t &()

template<typename source_t= source<>>
dx::clock<source_t>::operator event_t&()
inlinenoexcept

◆ operator event_t *()

template<typename source_t= source<>>
dx::clock<source_t>::operator event_t*()
inlinenoexcept

◆ run()

template<typename source_t= source<>>
virtual void dx::clock<source_t>::run()
inlinevirtual

create and start clock thread

Reimplemented in dx::stream::group< _device_t, source_t >, dx::stream::group< device_t, dx::source<> >, and dx::stream::group< device_t, source_t >.

Here is the caller graph for this function:

◆ self()

template<typename source_t= source<>>
bool dx::clock<source_t>::self() const
inlineprotected

the caller is the clock's own thread: a halt from its tick ends the loop, nobody joins it

◆ sync()

template<typename _event_t= event<user>, typename _clock_t= std::chrono::high_resolution_clock>
virtual void dx::source<_event_t, _clock_t>::sync(const typename clock_t::time_point& now)
inlinevirtualinherited
Here is the caller graph for this function:

◆ tick()

template<typename source_t= source<>>
virtual void dx::clock<source_t>::tick()
pure virtual

◆ wait()

template<typename _event_t= event<user>, typename _clock_t= std::chrono::high_resolution_clock>
virtual source& dx::source<_event_t, _clock_t>::wait(bool reset= false)
inlinevirtualinherited

Reimplemented in dx::free_run< event_t, clock_t >, dx::timer< event_t, clock_t >, dx::timer< dx::event< kernel >, frame >, and dx::usb::clock::source< device_t >.

Here is the caller graph for this function:

Member Data Documentation

◆ condition_variable

template<typename _event_t= event<user>, typename _clock_t= std::chrono::high_resolution_clock>
std::condition_variable dx::source<_event_t, _clock_t>::condition_variable
protectedinherited

◆ event

template<typename _event_t= event<user>, typename _clock_t= std::chrono::high_resolution_clock>
_event_t dx::source<_event_t, _clock_t>::event
protectedinherited
Todo
evaluate clock::status replacement (exception?)

◆ mutex

template<typename _event_t= event<user>, typename _clock_t= std::chrono::high_resolution_clock>
std::mutex dx::source<_event_t, _clock_t>::mutex
protectedinherited

◆ objective

template<typename _event_t= event<user>, typename _clock_t= std::chrono::high_resolution_clock>
_clock_t::time_point dx::source<_event_t, _clock_t>::objective
protectedinherited

◆ running

template<typename _event_t= event<user>, typename _clock_t= std::chrono::high_resolution_clock>
std::atomic<bool> dx::source<_event_t, _clock_t>::running{false}
protectedinherited

◆ status

template<typename _event_t= event<user>, typename _clock_t= std::chrono::high_resolution_clock>
os_result dx::source<_event_t, _clock_t>::status{not_initialized}
protectedinherited

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