From 0ab64b162f5d001ee095958acf6c3bf6c2fad92d Mon Sep 17 00:00:00 2001 From: Bart de Water Date: Sun, 29 Jul 2018 14:58:03 -0400 Subject: Only use CLOCK_PROCESS_CPUTIME_ID if it's defined It's not defined on JRuby and unlike monotonic time, concurrent-ruby doesn't have an cross-platform abstraction for this. --- activesupport/lib/active_support/notifications/instrumenter.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'activesupport/lib') diff --git a/activesupport/lib/active_support/notifications/instrumenter.rb b/activesupport/lib/active_support/notifications/instrumenter.rb index 455b7a44a6..f8344912bb 100644 --- a/activesupport/lib/active_support/notifications/instrumenter.rb +++ b/activesupport/lib/active_support/notifications/instrumenter.rb @@ -130,8 +130,14 @@ module ActiveSupport Process.clock_gettime(Process::CLOCK_MONOTONIC) end - def now_cpu - Process.clock_gettime(Process::CLOCK_PROCESS_CPUTIME_ID) + if defined?(Process::CLOCK_PROCESS_CPUTIME_ID) + def now_cpu + Process.clock_gettime(Process::CLOCK_PROCESS_CPUTIME_ID) + end + else + def now_cpu + 0 + end end if defined?(JRUBY_VERSION) -- cgit v1.2.3