Module: NewRelic::LanguageSupport
Defined Under Namespace
Modules: Control, SynchronizedHash
Constant Summary
collapse
- @@forkable =
nil
Instance Method Summary
collapse
Instance Method Details
#can_fork? ⇒ Boolean
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/new_relic/language_support.rb', line 41
def can_fork?
return @@forkable if @@forkable != nil
if Process.respond_to?(:fork)
@@forkable = ::RUBY_VERSION < '1.9.2' ? test_forkability : true
else
@@forkable = false
end
@@forkable
end
|
#test_forkability ⇒ Object
98
99
100
101
102
103
104
105
106
|
# File 'lib/new_relic/language_support.rb', line 98
def test_forkability
child = Process.fork { exit! }
Process.wait child
true
rescue NotImplementedError
false
end
|
#using_engine?(engine) ⇒ Boolean
55
56
57
58
59
60
61
|
# File 'lib/new_relic/language_support.rb', line 55
def using_engine?(engine)
if defined?(::RUBY_ENGINE)
::RUBY_ENGINE == engine
else
engine == 'ruby'
end
end
|
#using_version?(version) ⇒ Boolean
93
94
95
96
|
# File 'lib/new_relic/language_support.rb', line 93
def using_version?(version)
numbers = version.split('.')
numbers == ::RUBY_VERSION.split('.')[0, numbers.size]
end
|
#with_cautious_gc ⇒ Object
85
86
87
88
89
90
91
|
# File 'lib/new_relic/language_support.rb', line 85
def with_cautious_gc
if broken_gc?
with_disabled_gc { yield }
else
yield
end
end
|
#with_disabled_gc ⇒ Object
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
# File 'lib/new_relic/language_support.rb', line 70
def with_disabled_gc
if defined?(::GC) && ::GC.respond_to?(:disable)
val = nil
begin
::GC.disable
val = yield
ensure
::GC.enable
end
val
else
yield
end
end
|