source: vendor/synergy/1.3.1/lib/arch/CArchSleepWindows.cpp

Last change on this file was 2749, checked in by bird, 19 years ago

synergy v1.3.1 sources (zip).

File size: 1.4 KB
Line 
1/*
2 * synergy -- mouse and keyboard sharing utility
3 * Copyright (C) 2002 Chris Schoeneman
4 *
5 * This package is free software you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * found in the file COPYING that should have accompanied this file.
8 *
9 * This package is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 */
14
15#include "CArchSleepWindows.h"
16#include "CArch.h"
17#include "CArchMultithreadWindows.h"
18
19//
20// CArchSleepWindows
21//
22
23CArchSleepWindows::CArchSleepWindows()
24{
25 // do nothing
26}
27
28CArchSleepWindows::~CArchSleepWindows()
29{
30 // do nothing
31}
32
33void
34CArchSleepWindows::sleep(double timeout)
35{
36 ARCH->testCancelThread();
37 if (timeout < 0.0) {
38 return;
39 }
40
41 // get the cancel event from the current thread. this only
42 // works if we're using the windows multithread object but
43 // this is windows so that's pretty certain; we'll get a
44 // link error if we're not, though.
45 CArchMultithreadWindows* mt = CArchMultithreadWindows::getInstance();
46 if (mt != NULL) {
47 HANDLE cancelEvent = mt->getCancelEventForCurrentThread();
48 WaitForSingleObject(cancelEvent, (DWORD)(1000.0 * timeout));
49 if (timeout == 0.0) {
50 Sleep(0);
51 }
52 }
53 else {
54 Sleep((DWORD)(1000.0 * timeout));
55 }
56 ARCH->testCancelThread();
57}
Note: See TracBrowser for help on using the repository browser.