Class: IOPromise::ExecutorPool::Base
- Inherits:
-
Object
- Object
- IOPromise::ExecutorPool::Base
show all
- Defined in:
- lib/iopromise/executor_pool/base.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(connection_pool) ⇒ Base
13
14
15
16
|
# File 'lib/iopromise/executor_pool/base.rb', line 13
def initialize(connection_pool)
@connection_pool = connection_pool
@pending = []
end
|
Class Method Details
.for(connection_pool) ⇒ Object
7
8
9
10
|
# File 'lib/iopromise/executor_pool/base.rb', line 7
def for(connection_pool)
@executors ||= {}
@executors[connection_pool] ||= new(connection_pool)
end
|
Instance Method Details
#begin_executing(item) ⇒ Object
26
27
28
|
# File 'lib/iopromise/executor_pool/base.rb', line 26
def begin_executing(item)
item.beginning
end
|
#complete(item) ⇒ Object
22
23
24
|
# File 'lib/iopromise/executor_pool/base.rb', line 22
def complete(item)
@pending.delete(item)
end
|
#execute_continue(ready_readers, ready_writers, ready_exceptions) ⇒ Object
Continue execution of one or more pending IOPromises assigned to this pool. Returns [readers, writers, exceptions, max_timeout], which are arrays of the readers, writers, and exceptions to select on. The timeout specifies the maximum time to block waiting for one of these IO objects to become ready, after which this function is called again with empty “ready” arguments. Must be implemented by subclasses.
36
37
38
|
# File 'lib/iopromise/executor_pool/base.rb', line 36
def execute_continue(ready_readers, ready_writers, ready_exceptions)
raise NotImplementedError
end
|
#register(item) ⇒ Object
18
19
20
|
# File 'lib/iopromise/executor_pool/base.rb', line 18
def register(item)
@pending << item
end
|
#sync ⇒ Object
40
41
42
43
44
|
# File 'lib/iopromise/executor_pool/base.rb', line 40
def sync
@pending.each do |promise|
promise.sync if promise.is_a?(Promise)
end
end
|