mirror of
https://github.com/debauchee/barrier.git
synced 2026-02-08 21:03:54 +08:00
Reorganized source tree. Moved client.cpp into cmd/synergy as
synergy.cpp and server.cpp into cmd/synergyd as synergyd.cpp. Moved and renamed related files. Moved remaining source files into lib/.... Modified and added makefiles as appropriate. Result is that library files are under lib with each library in its own directory and program files are under cmd with each command in its own directory.
This commit is contained in:
42
lib/mt/CTimerThread.cpp
Normal file
42
lib/mt/CTimerThread.cpp
Normal file
@@ -0,0 +1,42 @@
|
||||
#include "CTimerThread.h"
|
||||
#include "CThread.h"
|
||||
#include "TMethodJob.h"
|
||||
#include "CLog.h"
|
||||
|
||||
//
|
||||
// CTimerThread
|
||||
//
|
||||
|
||||
CTimerThread::CTimerThread(double timeout) : m_timeout(timeout)
|
||||
{
|
||||
if (m_timeout >= 0.0) {
|
||||
m_callingThread = new CThread(CThread::getCurrentThread());
|
||||
m_timingThread = new CThread(new TMethodJob<CTimerThread>(
|
||||
this, &CTimerThread::timer));
|
||||
}
|
||||
else {
|
||||
m_callingThread = NULL;
|
||||
m_timingThread = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
CTimerThread::~CTimerThread()
|
||||
{
|
||||
if (m_timingThread != NULL) {
|
||||
log((CLOG_DEBUG1 "cancelling timeout"));
|
||||
m_timingThread->cancel();
|
||||
m_timingThread->wait();
|
||||
log((CLOG_DEBUG1 "cancelled timeout"));
|
||||
delete m_timingThread;
|
||||
delete m_callingThread;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CTimerThread::timer(void*)
|
||||
{
|
||||
log((CLOG_DEBUG1 "timeout in %f seconds", m_timeout));
|
||||
CThread::sleep(m_timeout);
|
||||
log((CLOG_DEBUG1 "timeout"));
|
||||
m_callingThread->cancel();
|
||||
}
|
||||
Reference in New Issue
Block a user