nitlanguage
/
nit.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
aa7a350
)
lib/core: intro `Float::sleep`
author
Alexis Laferrière
<alexis.laf@xymus.net>
Sat, 21 Nov 2015 21:57:58 +0000
(16:57 -0500)
committer
Alexis Laferrière
<alexis.laf@xymus.net>
Tue, 8 Dec 2015 16:11:17 +0000
(11:11 -0500)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>
lib/core/time.nit
patch
|
blob
|
history
diff --git
a/lib/core/time.nit
b/lib/core/time.nit
index
6c99016
..
5fc37f2
100644
(file)
--- a/
lib/core/time.nit
+++ b/
lib/core/time.nit
@@
-32,6
+32,16
@@
redef class Sys
`}
end
+redef class Float
+ # Sleep approximately `self` seconds
+ fun sleep `{
+ time_t s = self;
+ long ns = (self-s) * 1000000000.0;
+ const struct timespec req = {s, ns};
+ nanosleep(&req, NULL);
+ `}
+end
+
# Time since epoch
extern class TimeT `{time_t`}