class Syskit::NetworkGeneration::Async
A partially asynchronous requirement resolver built on top of {Engine}
Attributes
event_logger[R]
The {Roby::DRoby::EventLogger} used to log timings
future[R]
The future that does the async work
It is created by {#start}
@return [Resolution]
plan[R]
The target plan
thread_pool[R]
The thread pool (or, really, any of Concurrent executor)
Public Class Methods
new(plan, event_logger: plan.event_logger, thread_pool: Concurrent::CachedThreadPool.new)
click to toggle source
# File lib/syskit/network_generation/async.rb, line 25 def initialize(plan, event_logger: plan.event_logger, thread_pool: Concurrent::CachedThreadPool.new) @plan = plan @event_logger = event_logger @thread_pool = thread_pool end
Public Instance Methods
apply()
click to toggle source
# File lib/syskit/network_generation/async.rb, line 100 def apply engine = future.engine if future.fulfilled? required_instances = future.value begin engine.apply_system_network_to_plan(required_instances) rescue ::Exception => e engine.handle_resolution_exception(e, on_error: Engine.on_error) raise e end else engine.handle_resolution_exception(e, on_error: Engine.on_error) raise future.reason end end
cancel()
click to toggle source
# File lib/syskit/network_generation/async.rb, line 84 def cancel future.cancel end
finished?()
click to toggle source
# File lib/syskit/network_generation/async.rb, line 88 def finished? future.fulfilled? || future.rejected? end
join()
click to toggle source
# File lib/syskit/network_generation/async.rb, line 92 def join result = future.value if future.rejected? raise future.reason end result end
prepare(requirement_tasks = Engine.discover_requirement_tasks_from_plan(plan))
click to toggle source
# File lib/syskit/network_generation/async.rb, line 63 def prepare(requirement_tasks = Engine.discover_requirement_tasks_from_plan(plan)) future.cancel if future resolver = Resolution.new(plan, event_logger, requirement_tasks, executor: thread_pool) do Thread.current.name = 'syskit-async-resolution' log_timepoint_group 'syskit-async-resolution' do resolver.engine.resolve_system_network(requirement_tasks) end end @future = resolver end
start(requirement_tasks = Engine.discover_requirement_tasks_from_plan(plan))
click to toggle source
# File lib/syskit/network_generation/async.rb, line 74 def start(requirement_tasks = Engine.discover_requirement_tasks_from_plan(plan)) resolver = prepare(requirement_tasks) resolver.execute resolver end
transaction_committed?()
click to toggle source
# File lib/syskit/network_generation/async.rb, line 35 def transaction_committed? future.engine.work_plan.committed? end
transaction_finalized?()
click to toggle source
# File lib/syskit/network_generation/async.rb, line 31 def transaction_finalized? future.engine.work_plan.finalized? end
valid?(current = Engine.discover_requirement_tasks_from_plan(plan))
click to toggle source
# File lib/syskit/network_generation/async.rb, line 80 def valid?(current = Engine.discover_requirement_tasks_from_plan(plan)) current.to_set == future.requirement_tasks end