File: monotonic_time.rb

package info (click to toggle)
ruby-listen 3.9.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 544 kB
  • sloc: ruby: 5,033; makefile: 9
file content (27 lines) | stat: -rw-r--r-- 454 bytes parent folder | download | duplicates (2)
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
# frozen_string_literal: true

module Listen
  module MonotonicTime
    class << self
      if defined?(Process::CLOCK_MONOTONIC)

        def now
          Process.clock_gettime(Process::CLOCK_MONOTONIC)
        end

      elsif defined?(Process::CLOCK_MONOTONIC_RAW)

        def now
          Process.clock_gettime(Process::CLOCK_MONOTONIC_RAW)
        end

      else

        def now
          Time.now.to_f
        end

      end
    end
  end
end