File: sleep.cc

package info (click to toggle)
gri 2.8.7-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 4,472 kB
  • ctags: 2,092
  • sloc: cpp: 33,255; lisp: 3,980; perl: 1,037; makefile: 668; sh: 301
file content (32 lines) | stat: -rw-r--r-- 522 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include	"gr.hh"
#include	"extern.hh"
#include	"GMatrix.hh"

#if defined(IS_MINGW32)
#include        <windows.h>
#endif


bool
sleepCmd()
{
	if (_nword != 2) {
		demonstrate_command_usage();
		NUMBER_WORDS_ERROR;
		return false;
	}
	double sec_f;
	if (!getdnum(_word[1], &sec_f)) {
		err("`sleep' can't read .sec. in `\\", _word[1], "'.", "\\");
		return false;
	}
	if (sec_f <= 0.0)
		return true;
	int sec = int(floor(0.5 + sec_f));
#if !defined(IS_MINGW32)
	sleep(sec); 
#else
	Sleep(sec*1000);
#endif
	return true;
}