1 /*
2  * DSFML - The Simple and Fast Multimedia Library for D
3  *
4  * Copyright (c) 2013 - 2017 Jeremy DeHaan (dehaan.jeremiah@gmail.com)
5  *
6  * This software is provided 'as-is', without any express or implied warranty.
7  * In no event will the authors be held liable for any damages arising from the
8  * use of this software.
9  *
10  * Permission is granted to anyone to use this software for any purpose,
11  * including commercial applications, and to alter it and redistribute it
12  * freely, subject to the following restrictions:
13  *
14  * 1. The origin of this software must not be misrepresented; you must not claim
15  * that you wrote the original software. If you use this software in a product,
16  * an acknowledgment in the product documentation would be appreciated but is
17  * not required.
18  *
19  * 2. Altered source versions must be plainly marked as such, and must not be
20  * misrepresented as being the original software.
21  *
22  * 3. This notice may not be removed or altered from any source distribution
23  */
24 
25 /// A module containing the sleep function.
26 module dsfml.system.sleep;
27 
28 import core.time;
29 
30 /**
31  * Make the current thread sleep for a given duration.
32  *
33  * sleep is the best way to block a program or one of its threads, as it doesn't
34  * consume any CPU power.
35  *
36  * Params:
37  *		duration = The length of time to sleep for
38  */
39 void sleep(Duration duration)
40 {
41 	import core.thread;
42 	Thread.sleep(duration);
43 }
44 
45 
46 unittest
47 {
48 	version(DSFML_Unittest_System)
49 	{
50 		import std.stdio;
51 
52 		writeln("Unit test for sleep function");
53 
54 		writeln("Start!(sleeping for 1 second)");
55 		sleep(seconds(1));
56 		writeln("Done! Now sleeping for 2 seconds.");
57 		sleep(seconds(2));
58 		writeln("Done! I think you get the idea.");
59 		writeln();
60 	}
61 }