Sha256: 478655ddbd4ec0b611b956cfef165c058154172bfd418f7276022eb8edc939c4

Contents?: true

Size: 1.7 KB

Versions: 1

Compression:

Stored size: 1.7 KB

Contents

module Mutant
  # Runner baseclass
  class Runner
    include Adamantium::Flat, Concord.new(:env), Procto.call(:result)

    # Status of the runner execution
    class Status
      include Adamantium, Anima::Update, Anima.new(
        :env_result,
        :active_jobs,
        :done
      )
    end # Status

    # Job to push to workers
    class Job
      include Adamantium::Flat, Anima.new(:index, :mutation)
    end # Job

    # Job result object received from workers
    class JobResult
      include Adamantium::Flat, Anima.new(:job, :result)
    end

    REPORT_FREQUENCY = 20.0
    REPORT_DELAY     = 1 / REPORT_FREQUENCY

    # Initialize object
    #
    # @return [undefined]
    #
    # @api private
    #
    def initialize(*)
      super

      reporter.start(env)
      config.integration.setup

      @master = config.actor_env.current.bind(Master.call(env))

      status = nil

      loop do
        status = current_status
        break if status.done
        reporter.progress(status)
        Kernel.sleep(REPORT_DELAY)
      end

      reporter.progress(status)

      @master.call(:stop)

      @result = status.env_result

      reporter.report(@result)
    end

    # Return result
    #
    # @return [Result::Env]
    #
    # @api private
    #
    attr_reader :result

  private

    # Return reporter
    #
    # @return [Reporter]
    #
    # @api private
    #
    def reporter
      env.config.reporter
    end

    # Return config
    #
    # @return [Config]
    #
    # @api private
    #
    def config
      env.config
    end

    # Return current status
    #
    # @return [Status]
    #
    # @api private
    #
    def current_status
      @master.call(:status)
    end

  end # Runner
end # Mutant

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mutant-0.7.1 lib/mutant/runner.rb