2002-08-02 23:57:46 +04:00
|
|
|
/*
|
|
|
|
* synergy -- mouse and keyboard sharing utility
|
|
|
|
* Copyright (C) 2002 Chris Schoeneman
|
|
|
|
*
|
|
|
|
* This package is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* found in the file COPYING that should have accompanied this file.
|
|
|
|
*
|
|
|
|
* This package is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*/
|
|
|
|
|
2001-10-06 18:13:28 +04:00
|
|
|
#ifndef CTIMERTHREAD_H
|
|
|
|
#define CTIMERTHREAD_H
|
|
|
|
|
|
|
|
class CThread;
|
|
|
|
|
2002-07-28 17:34:19 +04:00
|
|
|
//! A timer thread
|
|
|
|
/*!
|
|
|
|
An object of this class cancels the thread that called the c'tor unless
|
|
|
|
the object is destroyed before a given timeout.
|
|
|
|
*/
|
2001-10-06 18:13:28 +04:00
|
|
|
class CTimerThread {
|
2002-04-29 18:40:01 +04:00
|
|
|
public:
|
2002-07-28 17:34:19 +04:00
|
|
|
//! Cancel calling thread after \c timeout seconds
|
|
|
|
/*!
|
|
|
|
Cancels the calling thread after \c timeout seconds unless destroyed
|
|
|
|
before then. If \c timeout is less than zero then it never times
|
|
|
|
out and this is a no-op.
|
|
|
|
*/
|
2001-10-06 18:13:28 +04:00
|
|
|
CTimerThread(double timeout);
|
2002-07-28 17:34:19 +04:00
|
|
|
//! Cancel the timer thread
|
2001-10-06 18:13:28 +04:00
|
|
|
~CTimerThread();
|
|
|
|
|
2002-04-29 18:40:01 +04:00
|
|
|
private:
|
2001-10-06 18:13:28 +04:00
|
|
|
void timer(void*);
|
|
|
|
|
|
|
|
// not implemented
|
|
|
|
CTimerThread(const CTimerThread&);
|
|
|
|
CTimerThread& operator=(const CTimerThread&);
|
|
|
|
|
2002-04-29 18:40:01 +04:00
|
|
|
private:
|
2001-10-06 18:13:28 +04:00
|
|
|
double m_timeout;
|
|
|
|
CThread* m_callingThread;
|
|
|
|
CThread* m_timingThread;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|