2 Copyright 2004-2005 Chris Tallon
4 This file is part of VOMP.
6 VOMP is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 VOMP is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with VOMP; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
33 #include "timerreceiver.h"
36 #include "threadwin.h"
45 Call setTimer to set a timer.... cancelTimer to delete a running timer.
46 Derive your object from TimerReceiver (timerreceiver.h), implement timercall() in your class
47 and supply your 'this' pointer to setTimer.
49 Once a timer has fired it does not exist anymore, you have to keep creating them if you want
52 clientReference is any int of your choice. It will be supplied back to you in the timercall()
53 so you can identify which timer has fired if you have more than one.
55 You can reset a timer by calling setTimer again. This will not create 2 timers, it will overwrite the first one.
57 You must not allow a timer to fire on an object that has been deleted already, unless you want
65 TimerReceiver* client;
67 struct timespec requestedTime;
71 //using namespace __gnu_cxx;
72 typedef list<Timer*> TimerList;
74 class Timers : public Thread_TYPE
79 static Timers* getInstance();
84 int setTimerT(TimerReceiver* client, int clientReference, long int requestedTime, long int requestedTimeNSEC=0);
85 int setTimerD(TimerReceiver* client, int clientReference, long int requestedSecs, long int requestedNSecs=0);
86 int cancelTimer(TimerReceiver* client, int clientReference);
89 virtual void threadMethod();
90 virtual void threadPostStopCleanup() {};
93 static Timers* instance;