]> git.mxchange.org Git - simgear.git/blob - simgear/misc/sg_sleep.cxx
a52880c5c087f4abfdbd2bc2f7b6a9f93040e760
[simgear.git] / simgear / misc / sg_sleep.cxx
1
2 // Written by James Turner, started July 2010.
3 //
4 // Copyright (C) 2010  Curtis L. Olson - http://www.flightgear.org/~curt
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Library General Public
8 // License as published by the Free Software Foundation; either
9 // version 2 of the License, or (at your option) any later version.
10 //
11 // This library 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 GNU
14 // Library General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19 //
20 // $Id$
21
22 #include <simgear/misc/sg_sleep.hxx>
23
24 #ifdef SG_WINDOWS
25 # include <windows.h>
26 #else
27 # include <unistd.h>
28 #endif
29
30 namespace simgear
31 {
32
33 #ifdef SG_WINDOWS
34
35 void sleepForSeconds(int seconds)
36 {
37   Sleep(1000 * seconds);
38 }
39
40 void sleepForMSec(int msec)
41 {
42   Sleep(msec);
43 }
44
45 #else
46
47 void sleepForSeconds(int seconds)
48 {
49   ::sleep(seconds);
50 }
51
52 void sleepForMSec(int msec)
53 {
54   ::usleep(msec * 1000);
55 }
56
57 #endif
58
59 } // of namespace simhear
60