class IOPromise::ExecutorPool::Base

Attributes

select_timeout[RW]

Public Class Methods

for(connection_pool) click to toggle source
# File lib/iopromise/executor_pool/base.rb, line 11
def for(connection_pool)
  @executors ||= {}
  @executors[connection_pool] ||= new(connection_pool)
end
new(connection_pool) click to toggle source
# File lib/iopromise/executor_pool/base.rb, line 19
def initialize(connection_pool)
  @connection_pool = connection_pool
  @pending = []

  @monitors = {}

  @select_timeout = nil
end

Public Instance Methods

begin_executing(item) click to toggle source
# File lib/iopromise/executor_pool/base.rb, line 43
def begin_executing(item)
  item.beginning
end
execute_continue() click to toggle source

Continue execution of one or more pending IOPromises assigned to this pool. Implementations may choose to pre-register IO handled using:

ExecutorContext.current.register_observer_io(...)

Alternatively, they can be registered when this function is called. During this function, implementations should check for timeouts and run any housekeeping operations.

Must be implemented by subclasses.

# File lib/iopromise/executor_pool/base.rb, line 55
def execute_continue
  raise NotImplementedError
end
promise_cancelled(item) click to toggle source
# File lib/iopromise/executor_pool/base.rb, line 39
def promise_cancelled(item)
  @pending.delete(item)
end
promise_fulfilled(_value, item) click to toggle source
# File lib/iopromise/executor_pool/base.rb, line 33
def promise_fulfilled(_value, item)
  @pending.delete(item)
end
promise_rejected(_reason, item) click to toggle source
# File lib/iopromise/executor_pool/base.rb, line 36
def promise_rejected(_reason, item)
  @pending.delete(item)
end
register(item) click to toggle source
# File lib/iopromise/executor_pool/base.rb, line 28
def register(item)
  @pending << item
  item.subscribe(self, item, item)
end
sync() click to toggle source
# File lib/iopromise/executor_pool/base.rb, line 59
def sync
  @pending.each do |promise|
    promise.sync if promise.is_a?(Promise)
  end
end