Sha256: eb3c77f8c929b34447de1c0ec2e2c7419351a439eef13edb4925f01f78672dd4

Contents?: true

Size: 859 Bytes

Versions: 6

Compression:

Stored size: 859 Bytes

Contents

# -*- coding: utf-8 -*-
require 'tengine/job'

# ForkやJoinの継承元となるVertex。特に状態は持たない。
class Tengine::Job::Junction < Tengine::Job::Vertex

  # https://cacoo.com/diagrams/hdLgrzYsTBBpV3Wj#D26C1
  def transmit(signal)
    complete_origin_edge(signal, :except_closed => true)
    # transmitted?で判断すると、closedなものに対する処理を考慮できないので、alive?を使って判断します
    # activate(signal) if prev_edges.all?(&:transmitted?)
    execution = signal.execution
    predicate = execution.retry ? :alive_or_closing_or_closed? : :alive_or_closing?
    activate(signal) unless prev_edges.any?(&predicate)
  end

  def activatable?
    prev_edges.all?(&:transmitted?)
  end

  def activate(signal)
    signal.leave(self)
  end

  def reset(signal)
    signal.leave(self, :reset)
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
tengine_job-1.1.0 lib/tengine/job/junction.rb
tengine_job-0.6.13 lib/tengine/job/junction.rb
tengine_job-0.6.12 lib/tengine/job/junction.rb
tengine_job-0.6.11 lib/tengine/job/junction.rb
tengine_job-0.6.10 lib/tengine/job/junction.rb
tengine_job-0.6.9 lib/tengine/job/junction.rb