File tree Expand file tree Collapse file tree 6 files changed +54
-1
lines changed
Expand file tree Collapse file tree 6 files changed +54
-1
lines changed Original file line number Diff line number Diff line change 55module Concurrent
66
77 module Executor
8+
9+ # @!macro [attach] executor_module_method_can_overflow_question
10+ #
11+ # Does the task queue have a maximum size?
12+ #
13+ # @return [Boolean] True if the task queue has a maximum size else false.
14+ #
15+ # @note Always returns `false`
816 def can_overflow?
917 false
1018 end
19+
20+ # @!macro [attach] executor_module_method_serialized_question
21+ #
22+ # Does this executor guarantee serialization of its operations?
23+ #
24+ # @return [Boolean] True if the executor guarantees that all operations
25+ # will be post in the order they are received and no two operations may
26+ # occur simultaneously. Else false.
27+ #
28+ # @note Always returns `false`
29+ def serialized?
30+ false
31+ end
32+ end
33+
34+ # Indicates that the including `Executor` or `ExecutorService` guarantees
35+ # that all operations will occur in the order they are post and that no
36+ # two operations may occur simultaneously. This module provides no
37+ # functionality and provides no guarantees. That is the responsibility
38+ # of the including class. This module exists solely to allow the including
39+ # object to be interrogated for its serialization status.
40+ #
41+ # @example
42+ # class Foo
43+ # include Concurrent::SerialExecutor
44+ # end
45+ #
46+ # foo = Foo.new
47+ #
48+ # foo.is_a? Concurrent::Executor #=> true
49+ # foo.is_a? Concurrent::SerialExecutor #=> true
50+ # foo.serialized? #=> true
51+ module SerialExecutor
52+ include Executor
53+
54+ # @!macro executor_module_method_serialized_question
55+ #
56+ # @note Always returns `true`
57+ def serialized?
58+ true
59+ end
1160 end
1261
1362 module RubyExecutor
Original file line number Diff line number Diff line change 33
44module Concurrent
55 class ImmediateExecutor
6- include Executor
6+ include SerialExecutor
77
88 def initialize
99 @stopped = Concurrent ::Event . new
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ module Concurrent
66 # @!macro single_thread_executor
77 class JavaSingleThreadExecutor
88 include JavaExecutor
9+ include SerialExecutor
910
1011 # Create a new thread pool.
1112 #
Original file line number Diff line number Diff line change @@ -90,6 +90,7 @@ def initialize(opts = {})
9090 set_shutdown_hook
9191 end
9292
93+ # @!macro executor_module_method_can_overflow_question
9394 def can_overflow?
9495 @max_queue != 0
9596 end
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ module Concurrent
55 # @!macro single_thread_executor
66 class RubySingleThreadExecutor
77 include RubyExecutor
8+ include SerialExecutor
89
910 # Create a new thread pool.
1011 #
Original file line number Diff line number Diff line change @@ -100,6 +100,7 @@ def initialize(opts = {})
100100 @last_gc_time = Time . now . to_f - [ 1.0 , ( @gc_interval * 2.0 ) ] . max
101101 end
102102
103+ # @!macro executor_module_method_can_overflow_question
103104 def can_overflow?
104105 @max_queue != 0
105106 end
You can’t perform that action at this time.
0 commit comments