SNode.C
Loading...
Searching...
No Matches
core::TimerEventPublisher Class Reference

#include <TimerEventPublisher.h>

Collaboration diagram for core::TimerEventPublisher:

Classes

class  timernode_lt
 

Public Member Functions

 TimerEventPublisher ()=default
 
utils::Timeval getNextTimeout (const utils::Timeval &currentTime)
 
void spanActiveEvents (const utils::Timeval &currentTime)
 
void unobserveDisableEvents ()
 
void remove (TimerEventReceiver *timer)
 
void erase (TimerEventReceiver *timer)
 
void insert (TimerEventReceiver *timer)
 
bool empty ()
 
void stop ()
 

Private Attributes

std::set< TimerEventReceiver *, timernode_lttimerList
 
std::list< TimerEventReceiver * > removedList
 

Detailed Description

Definition at line 60 of file TimerEventPublisher.h.

Constructor & Destructor Documentation

◆ TimerEventPublisher()

core::TimerEventPublisher::TimerEventPublisher ( )
default

Member Function Documentation

◆ empty()

bool core::TimerEventPublisher::empty ( )

Definition at line 98 of file TimerEventPublisher.cpp.

98 {
99 return timerList.empty();
100 }
std::set< TimerEventReceiver *, timernode_lt > timerList

References timerList.

Referenced by core::EventMultiplexer::waitForEvents().

Here is the caller graph for this function:

◆ erase()

void core::TimerEventPublisher::erase ( TimerEventReceiver timer)

Definition at line 90 of file TimerEventPublisher.cpp.

90 {
91 timerList.erase(timer);
92 }

References timerList.

Referenced by core::TimerEventReceiver::restart(), and core::TimerEventReceiver::update().

Here is the caller graph for this function:

◆ getNextTimeout()

utils::Timeval core::TimerEventPublisher::getNextTimeout ( const utils::Timeval currentTime)

Definition at line 55 of file TimerEventPublisher.cpp.

55 {
56 utils::Timeval nextTimeout({LONG_MAX, 0});
57
58 if (!timerList.empty()) {
59 nextTimeout = (*(timerList.begin()))->getTimeoutRelative(currentTime);
60 }
61
62 return nextTimeout;
63 }

References core::TimerEventReceiver::getTimeoutRelative(), utils::Timeval::operator=(), timerList, and utils::Timeval::Timeval().

Referenced by core::EventMultiplexer::getNextTimeout().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ insert()

void core::TimerEventPublisher::insert ( TimerEventReceiver timer)

Definition at line 94 of file TimerEventPublisher.cpp.

94 {
95 timerList.insert(timer);
96 }

References timerList.

Referenced by core::TimerEventReceiver::enable(), core::TimerEventReceiver::restart(), and core::TimerEventReceiver::update().

Here is the caller graph for this function:

◆ remove()

void core::TimerEventPublisher::remove ( TimerEventReceiver timer)

Definition at line 83 of file TimerEventPublisher.cpp.

83 {
84 if (std::find(timerList.begin(), timerList.end(), timer) != timerList.end() &&
85 std::find(removedList.begin(), removedList.end(), timer) == removedList.end()) {
86 removedList.push_back(timer);
87 }
88 }
std::list< TimerEventReceiver * > removedList

References removedList, and timerList.

Referenced by core::TimerEventReceiver::cancel(), and stop().

Here is the caller graph for this function:

◆ spanActiveEvents()

void core::TimerEventPublisher::spanActiveEvents ( const utils::Timeval currentTime)

Definition at line 65 of file TimerEventPublisher.cpp.

65 {
66 for (TimerEventReceiver* timerEventReceiver : timerList) {
67 if (timerEventReceiver->getTimeoutAbsolut() <= currentTime) {
68 timerEventReceiver->span();
69 } else {
70 break;
71 }
72 }
73 }

References core::TimerEventReceiver::getTimeoutAbsolut(), utils::Timeval::operator<=(), core::EventReceiver::span(), and timerList.

Referenced by core::EventMultiplexer::spanActiveEvents().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ stop()

void core::TimerEventPublisher::stop ( )

Definition at line 102 of file TimerEventPublisher.cpp.

102 {
103 for (TimerEventReceiver* timer : timerList) { // cppcheck-suppress constVariablePointer
104 remove(timer);
105 }
106
108 }
void remove(TimerEventReceiver *timer)

References remove(), timerList, and unobserveDisableEvents().

Referenced by core::EventMultiplexer::signal(), and core::EventMultiplexer::terminate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ unobserveDisableEvents()

void core::TimerEventPublisher::unobserveDisableEvents ( )

Definition at line 75 of file TimerEventPublisher.cpp.

75 {
76 for (TimerEventReceiver* timerEventReceiver : removedList) {
77 timerList.erase(timerEventReceiver);
78 timerEventReceiver->unobservedEvent();
79 }
80 removedList.clear();
81 }

References removedList, timerList, and core::TimerEventReceiver::unobservedEvent().

Referenced by core::EventMultiplexer::releaseExpiredResources(), and stop().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ removedList

std::list<TimerEventReceiver*> core::TimerEventPublisher::removedList
private

Definition at line 85 of file TimerEventPublisher.h.

Referenced by remove(), and unobserveDisableEvents().

◆ timerList

std::set<TimerEventReceiver*, timernode_lt> core::TimerEventPublisher::timerList
private

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