aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
diff options
context:
space:
mode:
authorBart de Water <bartdewater@gmail.com>2018-07-29 14:58:03 -0400
committerBart de Water <bartdewater@gmail.com>2018-07-29 14:58:03 -0400
commit0ab64b162f5d001ee095958acf6c3bf6c2fad92d (patch)
treea0e5e4fda7b0773a33823d325481ecb7b217a387 /activesupport
parent975fa15b47e4ef47a3b46f0e946860a076167149 (diff)
downloadrails-0ab64b162f5d001ee095958acf6c3bf6c2fad92d.tar.gz
rails-0ab64b162f5d001ee095958acf6c3bf6c2fad92d.tar.bz2
rails-0ab64b162f5d001ee095958acf6c3bf6c2fad92d.zip
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.
Diffstat (limited to 'activesupport')
-rw-r--r--activesupport/lib/active_support/notifications/instrumenter.rb10
1 files changed, 8 insertions, 2 deletions
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)