Sha256: 9f30fa4d18baf16ed226228427f0245544671b00bf79bb77471052102135a0e4

Contents?: true

Size: 1.69 KB

Versions: 6

Compression:

Stored size: 1.69 KB

Contents

module Mutant
  # Parallel execution engine of arbitrary payloads
  module Parallel

    # Driver for parallelized execution
    class Driver
      include Concord.new(:binding)

      # Scheduler status
      #
      # @return [Object]
      def status
        binding.call(__method__)
      end

      # Stop master gracefully
      #
      # @return [self]
      def stop
        binding.call(__method__)
        self
      end
    end # Driver

    # Run async computation returning driver
    #
    # @return [Driver]
    def self.async(config)
      Driver.new(config.env.new_mailbox.bind(Master.call(config)))
    end

    # Job result sink
    class Sink
      include AbstractType

      # Process job result
      #
      # @param [Object]
      #
      # @return [self]
      abstract_method :result

      # Sink status
      #
      # @return [Object]
      abstract_method :status

      # Test if processing should stop
      #
      # @return [Boolean]
      abstract_method :stop?
    end # Sink

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

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

    # Parallel run configuration
    class Config
      include Adamantium::Flat, Anima.new(
        :env,
        :jobs,
        :processor,
        :sink,
        :source
      )
    end # Config

    # Parallel execution status
    class Status
      include Adamantium::Flat, Anima.new(
        :active_jobs,
        :done,
        :payload
      )
    end # Status

  end # Parallel
end # Mutant

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mutant-0.8.16 lib/mutant/parallel.rb
mutant-0.8.15 lib/mutant/parallel.rb
mutant-0.8.14 lib/mutant/parallel.rb
mutant-0.8.13 lib/mutant/parallel.rb
mutant-0.8.12 lib/mutant/parallel.rb
mutant-0.8.11 lib/mutant/parallel.rb