@@ -11,37 +11,6 @@ module Concurrent
11
11
extend Concern ::Logging
12
12
extend Concern ::Deprecation
13
13
14
- # Suppresses all output when used for logging.
15
- NULL_LOGGER = lambda { |level , progname , message = nil , &block | }
16
-
17
- # @!visibility private
18
- GLOBAL_LOGGER = AtomicReference . new ( NULL_LOGGER )
19
- private_constant :GLOBAL_LOGGER
20
-
21
- # @!visibility private
22
- GLOBAL_FAST_EXECUTOR = Delay . new { Concurrent . new_fast_executor ( auto_terminate : true ) }
23
- private_constant :GLOBAL_FAST_EXECUTOR
24
-
25
- # @!visibility private
26
- GLOBAL_IO_EXECUTOR = Delay . new { Concurrent . new_io_executor ( auto_terminate : true ) }
27
- private_constant :GLOBAL_IO_EXECUTOR
28
-
29
- # @!visibility private
30
- GLOBAL_TIMER_SET = Delay . new { TimerSet . new ( auto_terminate : true ) }
31
- private_constant :GLOBAL_TIMER_SET
32
-
33
- # @!visibility private
34
- GLOBAL_IMMEDIATE_EXECUTOR = ImmediateExecutor . new
35
- private_constant :GLOBAL_IMMEDIATE_EXECUTOR
36
-
37
- def self . global_logger
38
- GLOBAL_LOGGER . value
39
- end
40
-
41
- def self . global_logger = ( value )
42
- GLOBAL_LOGGER . value = value
43
- end
44
-
45
14
# @return [Logger] Logger with provided level and output.
46
15
def self . create_stdlib_logger ( level = Logger ::FATAL , output = $stderr)
47
16
logger = Logger . new ( output )
@@ -62,17 +31,48 @@ def self.create_stdlib_logger(level = Logger::FATAL, output = $stderr)
62
31
progname ,
63
32
formatted_message
64
33
end
65
- logger
34
+
35
+ lambda do |level , progname , message = nil , &block |
36
+ logger . add level , message , progname , &block
37
+ end
66
38
end
67
39
68
40
# Use logger created by #create_stdlib_logger to log concurrent-ruby messages.
69
41
def self . use_stdlib_logger ( level = Logger ::FATAL , output = $stderr)
70
- logger = create_stdlib_logger level , output
71
- Concurrent . global_logger = lambda do |level , progname , message = nil , &block |
72
- logger . add level , message , progname , &block
73
- end
42
+ Concurrent . global_logger = create_stdlib_logger level , output
74
43
end
75
44
45
+ # Suppresses all output when used for logging.
46
+ NULL_LOGGER = lambda { |level , progname , message = nil , &block | }
47
+
48
+ # @!visibility private
49
+ GLOBAL_LOGGER = AtomicReference . new ( create_stdlib_logger ( Logger ::WARN ) )
50
+ private_constant :GLOBAL_LOGGER
51
+
52
+ def self . global_logger
53
+ GLOBAL_LOGGER . value
54
+ end
55
+
56
+ def self . global_logger = ( value )
57
+ GLOBAL_LOGGER . value = value
58
+ end
59
+
60
+ # @!visibility private
61
+ GLOBAL_FAST_EXECUTOR = Delay . new { Concurrent . new_fast_executor ( auto_terminate : true ) }
62
+ private_constant :GLOBAL_FAST_EXECUTOR
63
+
64
+ # @!visibility private
65
+ GLOBAL_IO_EXECUTOR = Delay . new { Concurrent . new_io_executor ( auto_terminate : true ) }
66
+ private_constant :GLOBAL_IO_EXECUTOR
67
+
68
+ # @!visibility private
69
+ GLOBAL_TIMER_SET = Delay . new { TimerSet . new ( auto_terminate : true ) }
70
+ private_constant :GLOBAL_TIMER_SET
71
+
72
+ # @!visibility private
73
+ GLOBAL_IMMEDIATE_EXECUTOR = ImmediateExecutor . new
74
+ private_constant :GLOBAL_IMMEDIATE_EXECUTOR
75
+
76
76
# Disables AtExit handlers including pool auto-termination handlers.
77
77
# When disabled it will be the application programmer's responsibility
78
78
# to ensure that the handlers are shutdown properly prior to application
@@ -275,4 +275,18 @@ def self.configuration
275
275
def self . configure
276
276
yield ( configuration )
277
277
end
278
+
279
+ # for dependency reasons this check cannot be in concurrent/synchronization
280
+ if Concurrent . on_jruby?
281
+ require 'java'
282
+
283
+ version_string = java . lang . System . getProperties [ 'java.runtime.version' ]
284
+ version = version_string . split ( '.' , 3 ) [ 0 ..1 ] . map ( &:to_i )
285
+ if ( version <=> [ 1 , 8 ] ) < 0
286
+ deprecated <<-TXT . gsub ( /^\s *\| / , '' ) . chop , 0
287
+ |Java 7 is deprecated, please use Java 8.
288
+ |Java 7 support is only best effort, it may not work. It will be removed in next release (1.0).
289
+ TXT
290
+ end
291
+ end
278
292
end
0 commit comments