Module: Syskit::Runtime::PlanExtension

Defined in:
lib/syskit/runtime/apply_requirement_modifications.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#syskit_current_resolutionNetworkGeneration::Async?

The currently running resolution

Returns:



12
13
14
# File 'lib/syskit/runtime/apply_requirement_modifications.rb', line 12

def syskit_current_resolution
  @syskit_current_resolution
end

#syskit_current_resolution_keepaliveObject

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



16
17
18
# File 'lib/syskit/runtime/apply_requirement_modifications.rb', line 16

def syskit_current_resolution_keepalive
  @syskit_current_resolution_keepalive
end

#syskit_resolution_poolConcurrent::CachedThreadPool

The thread pool used to resolve Syskit networks asynchronously

Returns:

  • (Concurrent::CachedThreadPool)


7
8
9
# File 'lib/syskit/runtime/apply_requirement_modifications.rb', line 7

def syskit_resolution_pool
  @syskit_resolution_pool
end

Instance Method Details

#syskit_apply_async_resolution_resultsObject

Apply a finished resolution on this plan

Raises:

  • (RuntimeError)

    if the current resolution is not finished.



76
77
78
79
80
81
82
83
84
85
86
87
# 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_resolutionObject

Cancels the currently running resolution



49
50
51
52
53
# 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?Boolean

True if the async part of the current resolution is finished

Returns:

  • (Boolean)


56
57
58
# File 'lib/syskit/runtime/apply_requirement_modifications.rb', line 56

def syskit_finished_async_resolution?
    syskit_current_resolution.finished?
end

#syskit_has_async_resolution?Boolean

True if Syskit is currently resolving a network

Returns:

  • (Boolean)


19
20
21
# File 'lib/syskit/runtime/apply_requirement_modifications.rb', line 19

def syskit_has_async_resolution?
    !!@syskit_current_resolution
end

#syskit_join_current_resolutionObject

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



68
69
70
71
# 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) ⇒ void

This method returns an undefined value.

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

Parameters:

Raises:



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# 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?Boolean

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

Returns:

  • (Boolean)


62
63
64
# File 'lib/syskit/runtime/apply_requirement_modifications.rb', line 62

def syskit_valid_async_resolution?
    syskit_current_resolution.valid?
end