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 5
5
module Concurrent
6
6
7
7
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`
8
16
def can_overflow?
9
17
false
10
18
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
11
60
end
12
61
13
62
module RubyExecutor
Original file line number Diff line number Diff line change 3
3
4
4
module Concurrent
5
5
class ImmediateExecutor
6
- include Executor
6
+ include SerialExecutor
7
7
8
8
def initialize
9
9
@stopped = Concurrent ::Event . new
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ module Concurrent
6
6
# @!macro single_thread_executor
7
7
class JavaSingleThreadExecutor
8
8
include JavaExecutor
9
+ include SerialExecutor
9
10
10
11
# Create a new thread pool.
11
12
#
Original file line number Diff line number Diff line change @@ -90,6 +90,7 @@ def initialize(opts = {})
90
90
set_shutdown_hook
91
91
end
92
92
93
+ # @!macro executor_module_method_can_overflow_question
93
94
def can_overflow?
94
95
@max_queue != 0
95
96
end
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ module Concurrent
5
5
# @!macro single_thread_executor
6
6
class RubySingleThreadExecutor
7
7
include RubyExecutor
8
+ include SerialExecutor
8
9
9
10
# Create a new thread pool.
10
11
#
Original file line number Diff line number Diff line change @@ -100,6 +100,7 @@ def initialize(opts = {})
100
100
@last_gc_time = Time . now . to_f - [ 1.0 , ( @gc_interval * 2.0 ) ] . max
101
101
end
102
102
103
+ # @!macro executor_module_method_can_overflow_question
103
104
def can_overflow?
104
105
@max_queue != 0
105
106
end
You can’t perform that action at this time.
0 commit comments