PVData C++
8.0.9
Toggle main menu visibility
Loading...
Searching...
No Matches
misc
pv
timer.h
1
/* timer.h */
2
/*
3
* Copyright information and license terms for this software can be
4
* found in the file LICENSE that is included with the distribution
5
*/
9
#ifndef TIMER_H
10
#define TIMER_H
11
#include <
memory
>
12
#include <
list
>
13
14
#include <stddef.h>
15
#include <
stdlib.h
>
16
#include <stddef.h>
17
#include <string.h>
18
#include <stdio.h>
19
20
#include <pv/pvType.h>
21
#include <pv/thread.h>
22
#include <pv/timeStamp.h>
23
#include <pv/event.h>
24
#include <pv/lock.h>
25
#include <
pv/sharedPtr.h
>
26
27
#include <shareLib.h>
28
29
namespace
epics
{
namespace
pvData
{
30
31
class
TimerCallback
;
32
class
Timer
;
33
typedef
std::tr1::shared_ptr<TimerCallback> TimerCallbackPtr;
34
typedef
std::tr1::shared_ptr<Timer> TimerPtr;
35
40
class
epicsShareClass
TimerCallback
{
41
public
:
42
POINTER_DEFINITIONS(
TimerCallback
);
46
TimerCallback
();
50
virtual
~TimerCallback
(){}
54
virtual
void
callback
() = 0;
58
virtual
void
timerStopped
() = 0;
59
private
:
60
epicsTime timeToRun;
61
double
period;
62
bool
onList;
63
bool
cancelled;
64
bool
processing;
65
friend
class
Timer;
66
struct
IncreasingTime;
67
};
68
73
class
epicsShareClass
Timer
:
private
Runnable {
74
public
:
75
POINTER_DEFINITIONS(
Timer
);
80
Timer
(
std::string
threadName, ThreadPriority priority);
81
virtual
~Timer
();
83
void
close
();
89
void
scheduleAfterDelay
(
90
TimerCallbackPtr
const
&timerCallback,
91
double
delay);
98
void
schedulePeriodic(
99
TimerCallbackPtr
const
&timerCallback,
100
double
delay,
101
double
period);
107
bool
cancel
(TimerCallbackPtr
const
&timerCallback);
113
bool
isScheduled
(TimerCallbackPtr
const
&timerCallback)
const
;
118
void
dump
(
std::ostream
& o)
const
;
119
120
private
:
121
virtual
void
run();
122
123
// call with mutex held
124
void
addElement(TimerCallbackPtr
const
&timerCallback);
125
126
typedef
std::list<TimerCallbackPtr>
queue_t;
127
128
mutable
Mutex mutex;
129
queue_t queue;
130
Event
waitForWork;
131
bool
waiting;
132
bool
alive;
133
Thread
thread;
134
};
135
136
epicsShareExtern
std::ostream
& operator<<(
std::ostream
& o,
const
Timer
& timer);
137
138
}}
139
#endif
/* TIMER_H */
stdlib.h
list
memory
std::ostream
basic_ostream< char > ostream
std::string
basic_string< char > string
std::list
epics::pvData::Event
C++ wrapper for epicsEvent from EPICS base.
Definition
event.h:31
epics::pvData::Thread
C++ wrapper for epicsThread from EPICS base.
Definition
thread.h:65
epics::pvData::TimerCallback
Class that must be implemented by code that makes Timer requests.
Definition
timer.h:40
epics::pvData::TimerCallback::~TimerCallback
virtual ~TimerCallback()
Definition
timer.h:50
epics::pvData::TimerCallback::callback
virtual void callback()=0
epics::pvData::TimerCallback::timerStopped
virtual void timerStopped()=0
epics::pvData::TimerCallback::TimerCallback
TimerCallback()
epics::pvData::Timer
Support for delayed or periodic callback execution.
Definition
timer.h:73
epics::pvData::Timer::dump
void dump(std::ostream &o) const
epics::pvData::Timer::close
void close()
Prevent new callbacks from being scheduled, and cancel pending callbacks.
epics::pvData::Timer::cancel
bool cancel(TimerCallbackPtr const &timerCallback)
epics::pvData::Timer::Timer
Timer(std::string threadName, ThreadPriority priority)
epics::pvData::Timer::isScheduled
bool isScheduled(TimerCallbackPtr const &timerCallback) const
epics::pvData::Timer::scheduleAfterDelay
void scheduleAfterDelay(TimerCallbackPtr const &timerCallback, double delay)
epics::pvData
pvData
Definition
convert.h:21
epics
epics
Definition
convert.h:21
sharedPtr.h
Generated on
for PVData C++ by
1.17.0