EPICS ARCHIVER V4
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups
Throttle.h
1 // -*- c++ -*-
2 #ifndef __THROTTLE_H__
3 #define __THROTTLE_H__
4 
5 // epics
6 #include <epicsTime.h>
7 
8 // tools
9 #include "tools/ToolsConfig.h"
10 #include "tools/OrderedMutex.h"
11 
19 class Throttle
20 {
21 public:
23  Throttle(const char *name, double seconds_between_messages);
24 
26  void reset();
27 
31  void fire();
32 
34  bool isPermitted(const epicsTime &when);
35 
37  bool isPermitted();
38 
41  {
42  return seconds;
43  }
44 
45 private:
46  PROHIBIT_DEFAULT_COPY(Throttle);
47  OrderedMutex mutex;
48  double seconds;
49  epicsTime last;
50 };
51 
52 #endif
53 
Throttle(const char *name, double seconds_between_messages)
Create throttle with the given name and threshold.
A mutex with informational name and lock order.
Definition: OrderedMutex.h:34
void reset()
Reset the throttle so that isPermitted will return &#39;true&#39;.
Timer for throttling messages, thread safe.
Definition: Throttle.h:19
void fire()
Fire the throttle so that isPermitted will return &#39;false&#39; until the threshold is exceeded.
double getThrottleThreshold()
Definition: Throttle.h:40
bool isPermitted()