Skip to content

Commit d0cc4fc

Browse files
committed
Merge pull request #46 from jdantonio/jruby-improvemnts
Code readability improvement
2 parents 7c525e2 + 481858e commit d0cc4fc

9 files changed

+17
-17
lines changed

lib/concurrent/atomic.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def initialize(init = 0)
109109
allocate_storage(init)
110110
end
111111

112-
if defined? java.util
112+
if RUBY_PLATFORM == 'java'
113113
include JavaAtomicFixnum
114114
else
115115
include MutexAtomicFixnum

lib/concurrent/cached_thread_pool.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,35 @@
22

33
module Concurrent
44

5-
if defined? java.util
5+
if RUBY_PLATFORM == 'java'
66
require 'concurrent/java_cached_thread_pool'
77
# @!macro [attach] cached_thread_pool
88
# A thread pool that dynamically grows and shrinks to fit the current workload.
99
# New threads are created as needed, existing threads are reused, and threads
1010
# that remain idle for too long are killed and removed from the pool. These
1111
# pools are particularly suited to applications that perform a high volume of
1212
# short-lived tasks.
13-
#
13+
#
1414
# On creation a +CachedThreadPool+ has zero running threads. New threads are
1515
# created on the pool as new operations are +#post+. The size of the pool
1616
# will grow until +#max_length+ threads are in the pool or until the number
1717
# of threads exceeds the number of running and pending operations. When a new
1818
# operation is post to the pool the first available idle thread will be tasked
1919
# with the new operation.
20-
#
20+
#
2121
# Should a thread crash for any reason the thread will immediately be removed
2222
# from the pool. Similarly, threads which remain idle for an extended period
2323
# of time will be killed and reclaimed. Thus these thread pools are very
2424
# efficient at reclaiming unused resources.
25-
#
25+
#
2626
# The API and behavior of this class are based on Java's +CachedThreadPool+
2727
#
2828
# @note When running on the JVM (JRuby) this class will inherit from +JavaCachedThreadPool+.
2929
# On all other platforms it will inherit from +RubyCachedThreadPool+.
3030
#
3131
# @see Concurrent::RubyCachedThreadPool
3232
# @see Concurrent::JavaCachedThreadPool
33-
#
33+
#
3434
# @see http://docs.oracle.com/javase/tutorial/essential/concurrency/pools.html
3535
# @see http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/Executors.html
3636
# @see http://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ExecutorService.html

lib/concurrent/fixed_thread_pool.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
module Concurrent
44

5-
if defined? java.util
5+
if RUBY_PLATFORM == 'java'
66
require 'concurrent/java_fixed_thread_pool'
77
# @!macro [attach] fixed_thread_pool
88
#
@@ -11,15 +11,15 @@ module Concurrent
1111
# tasks +#post+ to the thread pool are enqueued until a thread becomes available.
1212
# Should a thread crash for any reason the thread will immediately be removed
1313
# from the pool and replaced.
14-
#
14+
#
1515
# The API and behavior of this class are based on Java's +FixedThreadPool+
1616
#
1717
# @note When running on the JVM (JRuby) this class will inherit from +JavaFixedThreadPool+.
1818
# On all other platforms it will inherit from +RubyFixedThreadPool+.
1919
#
2020
# @see Concurrent::RubyFixedThreadPool
2121
# @see Concurrent::JavaFixedThreadPool
22-
#
22+
#
2323
# @see http://docs.oracle.com/javase/tutorial/essential/concurrency/pools.html
2424
# @see http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/Executors.html
2525
# @see http://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ExecutorService.html

lib/concurrent/java_cached_thread_pool.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
if defined? java.util
1+
if RUBY_PLATFORM == 'java'
22

33
require 'concurrent/java_thread_pool_executor'
44

lib/concurrent/java_fixed_thread_pool.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
if defined? java.util
1+
if RUBY_PLATFORM == 'java'
22

33
require 'concurrent/java_thread_pool_executor'
44

lib/concurrent/java_thread_pool_executor.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
if defined? java.util
1+
if RUBY_PLATFORM == 'java'
22

33
module Concurrent
44

lib/concurrent/processor_count.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ module Concurrent
3434
# @see http://docs.oracle.com/javase/6/docs/api/java/lang/Runtime.html#availableProcessors()
3535
# @see http://msdn.microsoft.com/en-us/library/aa394373(v=vs.85).aspx
3636
def processor_count
37-
if defined? java.lang
37+
if RUBY_PLATFORM == 'java'
3838
java.lang.Runtime.getRuntime.availableProcessors
3939
else
4040
@@processor_count ||= begin

lib/concurrent/thread_local_var.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class ThreadLocalVar
7575

7676
NIL_SENTINEL = Object.new
7777

78-
if defined? java.lang
78+
if RUBY_PLATFORM == 'java'
7979
include ThreadLocalJavaStorage
8080
elsif Thread.current.respond_to?(:thread_variable_set)
8181
include ThreadLocalNewStorage

lib/concurrent/thread_pool_executor.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22

33
module Concurrent
44

5-
if defined? java.util
5+
if RUBY_PLATFORM == 'java'
66
require 'concurrent/java_thread_pool_executor'
77
# @!macro [attach] thread_pool_executor
88
#
99
# A thread pool...
10-
#
10+
#
1111
# The API and behavior of this class are based on Java's +ThreadPoolExecutor+
1212
#
1313
# @note When running on the JVM (JRuby) this class will inherit from +JavaThreadPoolExecutor+.
1414
# On all other platforms it will inherit from +RubyThreadPoolExecutor+.
1515
#
1616
# @see Concurrent::RubyThreadPoolExecutor
1717
# @see Concurrent::JavaThreadPoolExecutor
18-
#
18+
#
1919
# @see http://docs.oracle.com/javase/tutorial/essential/concurrency/pools.html
2020
# @see http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/Executors.html
2121
# @see http://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ExecutorService.html

0 commit comments

Comments
 (0)