module Syskit::Runtime::PlanExtension

Attributes

syskit_current_resolution[RW]

The currently running resolution

@return [NetworkGeneration::Async,nil]

syskit_current_resolution_keepalive[RW]

A transaction used to protect all Syskit components from the plan GC during resolution

syskit_resolution_pool[RW]

The thread pool used to resolve Syskit networks asynchronously

@return [Concurrent::CachedThreadPool]

Public Instance Methods

syskit_apply_async_resolution_results() click to toggle source

Apply a finished resolution on this plan

@raise [RuntimeError] if the current resolution is not finished.

# File lib/syskit/runtime/apply_requirement_modifications.rb, line 76
def syskit_apply_async_resolution_results
    if !syskit_finished_async_resolution?
        raise RuntimeError, "the current network resolution is not yet finished"
    end

    begin
        syskit_current_resolution.apply
    ensure
        syskit_current_resolution_keepalive.discard_transaction
        @syskit_current_resolution = nil
    end
end
syskit_cancel_async_resolution() click to toggle source

Cancels the currently running resolution

# File lib/syskit/runtime/apply_requirement_modifications.rb, line 49
def syskit_cancel_async_resolution
    syskit_current_resolution.cancel
    syskit_current_resolution_keepalive.discard_transaction
    @syskit_current_resolution = nil
end
syskit_finished_async_resolution?() click to toggle source

True if the async part of the current resolution is finished

# File lib/syskit/runtime/apply_requirement_modifications.rb, line 56
def syskit_finished_async_resolution?
    syskit_current_resolution.finished?
end
syskit_has_async_resolution?() click to toggle source

True if Syskit is currently resolving a network

# File lib/syskit/runtime/apply_requirement_modifications.rb, line 19
def syskit_has_async_resolution?
    !!@syskit_current_resolution
end
syskit_join_current_resolution() click to toggle source

Wait for the current running resolution to finish, and apply it on the plan

# File lib/syskit/runtime/apply_requirement_modifications.rb, line 68
def syskit_join_current_resolution
    syskit_current_resolution.join
    Runtime.apply_requirement_modifications(self)
end
syskit_start_async_resolution(requirement_tasks) click to toggle source

Start the resolution of the network generated by the given requirement tasks

@param [Array<InstanceRequirementsTask>] requirement_tasks @raise [RuntimeError] if there is already a resolution. Call

{#syskit_cancel_async_resolution} first

@return [void]

# File lib/syskit/runtime/apply_requirement_modifications.rb, line 31
def syskit_start_async_resolution(requirement_tasks)
    if syskit_has_async_resolution?
        raise ArgumentError, "an async resolution is already running, call #syskit_cancel_async_resolution first"
    end

    @syskit_resolution_pool ||= Concurrent::CachedThreadPool.new
    # Protect all toplevel Syskit tasks while the resolution runs
    @syskit_current_resolution_keepalive = Roby::Transaction.new(self)
    find_local_tasks(Component).each do |component_task|
        if !component_task.finished?
            syskit_current_resolution_keepalive.wrap(component_task)
        end
    end
    @syskit_current_resolution = NetworkGeneration::Async.new(self, thread_pool: syskit_resolution_pool)
    syskit_current_resolution.start(requirement_tasks)
end
syskit_valid_async_resolution?() click to toggle source

True if the currently running resolution is valid w.r.t. the current plan's state

# File lib/syskit/runtime/apply_requirement_modifications.rb, line 62
def syskit_valid_async_resolution?
    syskit_current_resolution.valid?
end