Skip to content

Commit 0d48ff9

Browse files
committed
feat: define Roby.monotonic_time
It's a method I've defined on Syskit and started to use quite a bit on all timeout-related code in telemetry/. Given its applicability, I think best to move it here.
1 parent 2f2eb2f commit 0d48ff9

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lib/roby/support.rb

+9
Original file line numberDiff line numberDiff line change
@@ -207,4 +207,13 @@ def self.which(cmd)
207207

208208
VoidClass = Class.new
209209
Void = VoidClass.new.freeze
210+
211+
# Time in seconds since an arbitrary point in time, unaffected by time corrections
212+
#
213+
# Use this time for e.g. compute timeouts or durations since a certain timepoint
214+
#
215+
# @return [Float]
216+
def self.monotonic_time
217+
Process.clock_gettime(Process::CLOCK_MONOTONIC)
218+
end
210219
end

0 commit comments

Comments
 (0)