Sha256: cf8683fbce5552c7c4040c3752c8b6ef0a735a1c62eb7df5b7c59937bd56182f

Contents?: true

Size: 643 Bytes

Versions: 1

Compression:

Stored size: 643 Bytes

Contents

require 'celluloid'

module Rlyeh
  module Worker
    class ThreadPool
      include Celluloid

      def invoke(*args, &block)
        block.call *args if block
      end
    end

    class << self
      def included(base)
        base.extend ClassMethods
      end

      def setup(options = {})
        @worker_pool = ThreadPool.pool options
      end

      def worker_pool
        @worker_pool ||= setup
      end
    end

    module ClassMethods
      def worker_pool
        @worker_pool ||= Rlyeh::Worker.worker_pool
      end
    end

    def invoke(*args, &block)
      self.class.worker_pool.invoke *args, &block
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rlyeh-0.1.1 lib/rlyeh/worker.rb