Sha256: cffb4e9fa421cabc2dde448936a72fcd5ea11495b248a32e6e426fff9b7942a3

Contents?: true

Size: 612 Bytes

Versions: 3

Compression:

Stored size: 612 Bytes

Contents

require 'singleton'
require 'json'

module Populus
  class Pool
    include Singleton

    def objects
      @objects ||= []
    end

    class << self
      def register_object(o)
        instance.objects << o
        Populus.logger.info "Registered: #{o.inspect}"
      end

      # TODO: Trying Enumerable#lazy
      def events
        instance.objects.select {|o| o.type?('event') }
      end

      def find_events_by_name(name)
        events.select{|o| o.has_name?(name) }
      end

      def gen_threads
        instance.objects.map { |o|
          o.create_thread
        }
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
populus-0.0.4 lib/populus/pool.rb
populus-0.0.3 lib/populus/pool.rb
populus-0.0.1 lib/populus/pool.rb