nitlanguage
/
nit.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
src/model: model_json use MEntity::visibility
[nit.git]
/
lib
/
realtime.nit
diff --git
a/lib/realtime.nit
b/lib/realtime.nit
index
6e312ef
..
243b5d8
100644
(file)
--- a/
lib/realtime.nit
+++ b/
lib/realtime.nit
@@
-120,7
+120,22
@@
extern class Timespec `{struct timespec*`}
end
# Keeps track of real time
end
# Keeps track of real time
+#
+# ~~~
+# var clock = new Clock
+#
+# # sleeping at least 1s
+# 1.0.sleep
+# assert clock.total >= 1.0
+# assert clock.lapse >= 1.0
+#
+# # sleeping at least 5ms
+# 0.005.sleep
+# assert clock.total >= 1.005
+# assert clock.lapse >= 0.005
+# ~~~
class Clock
class Clock
+ super FinalizableOnce
# TODO use less mallocs
# TODO use less mallocs
@@
-181,4
+196,10
@@
class Clock
dt.free
return r
end
dt.free
return r
end
+
+ redef fun finalize_once
+ do
+ time_at_beginning.free
+ time_at_last_lapse.free
+ end
end
end