37 #include <ptlib_config.h>
51 #define PTIMER_OPERATORS(cls) \
52 cls & operator=( int16_t rhs) { this->SetInterval(rhs); return *this; } \
53 cls & operator=(uint16_t rhs) { this->SetInterval(rhs); return *this; } \
54 cls & operator=( int32_t rhs) { this->SetInterval(rhs); return *this; } \
55 cls & operator=(uint32_t rhs) { this->SetInterval(rhs); return *this; } \
56 cls & operator=( int64_t rhs) { this->SetInterval(rhs); return *this; } \
57 cls & operator=(uint64_t rhs) { this->SetInterval(rhs); return *this; } \
58 cls & operator=(const PTimeInterval & rhs) { this->SetInterval(rhs.GetMilliSeconds()); return *this; } \
85 long milliseconds = 0,
95 const PSimpleTimer & timer
111 const PSimpleTimer & timer
132 bool IsRunning()
const;
136 bool HasExpired()
const;
140 operator bool()
const;
188 long milliseconds = 0,
211 PTIMER_OPERATORS(PTimer);
290 virtual void OnTimeout();
372 virtual ~Timeout() { }
377 typedef std::map<PIdGenerator::Handle, PTimer *> TimerMap;
381 size_t m_highWaterMark;
387 static List * TimerList();
393 void InternalStart(
bool once, int64_t resetTime);
404 friend class Emitter;
408 #include "msos/ptlib/timer.h"
410 #include "unix/ptlib/timer.h"
441 class PPoolTimer :
public PTimer
448 PPoolTimer(Pool_T & pool)
459 virtual void OnTimeout()
463 Work_T * work = CreateWork();
465 m_pool.AddWork(work, GetGroup(*work));
468 virtual Work_T * CreateWork() = 0;
469 virtual const char * GetGroup(
const Work_T & )
const {
return NULL; }
471 PTIMER_OPERATORS(PPoolTimer);
478 class Base_T = Work_T,
481 class PPoolTimerArg0 :
public PPoolTimer<Base_T, Pool_T>
483 typedef PPoolTimer<Base_T, Pool_T> BaseClass;
486 PPoolTimerArg0(Pool_T & pool)
491 virtual Work_T * CreateWork() {
return new Work_T(); }
493 PTIMER_OPERATORS(PPoolTimerArg0);
501 class Base_T = Work_T,
504 class PPoolTimerArg1:
public PPoolTimer<Base_T, Pool_T>
506 typedef PPoolTimer<Base_T, Pool_T> BaseClass;
511 PPoolTimerArg1(Pool_T & pool, Arg1 arg1)
517 virtual Work_T * CreateWork() {
return new Work_T(m_arg1); }
519 PTIMER_OPERATORS(PPoolTimerArg1);
528 class Base_T = Work_T,
531 class PPoolTimerArg2:
public PPoolTimer<Base_T, Pool_T>
533 typedef PPoolTimer<Base_T, Pool_T> BaseClass;
539 PPoolTimerArg2(Pool_T & pool, Arg1 arg1, Arg2 arg2)
546 virtual Work_T * CreateWork() {
return new Work_T(m_arg1, m_arg2); }
548 PTIMER_OPERATORS(PPoolTimerArg2);
558 class Base_T = Work_T,
561 class PPoolTimerArg3:
public PPoolTimer<Base_T, Pool_T>
563 typedef PPoolTimer<Base_T, Pool_T> BaseClass;
570 PPoolTimerArg3(Pool_T & pool, Arg1 arg1, Arg2 arg2, Arg3 arg3)
578 virtual Work_T * CreateWork() {
return new Work_T(m_arg1, m_arg2, m_arg3); }
580 PTIMER_OPERATORS(PPoolTimerArg3);
594 #endif // PTLIB_TIMER_H
virtual void InternalSet(int64_t t)
This class defines an arbitrary time interval to millisecond accuracy.
Definition: timeint.h:51
#define PCLASSINFO(cls, par)
Declare all the standard PTLib class information.
Definition: object.h:2164
Class specialisation for PNotifierTemplate<P_INT_PTR>
This class implements critical section mutexes using the most efficient mechanism available on the ho...
Definition: mutex.h:270
unsigned int Handle
Definition: id_generator.h:46
PTimeInterval & operator=(const PTimeInterval &other)
High Level (queued work item) thread pool.
Definition: threadpool.h:383
bool PBoolean
Definition: object.h:174
#define PPROFILE_EXCLUDE(func)
Definition: object.h:1259
The character string class.
Definition: pstring.h:108
virtual void PrintOn(ostream &strm) const
Output the time interval to the I/O stream.
This class defines a thread mutual exclusion object.
Definition: mutex.h:101
static const PString & Empty()
Return an empty string.
virtual int64_t InternalGet() const
#define PCLASSINFO_WITH_CLONE(cls, par)
Declare all the standard PTLib class information, plus Clone().
Definition: object.h:2167