class Celluloid::SupervisionGroup::Member - celluloid-0.16.0 Documentation

# class Celluloid::SupervisionGroup::Member

A member of the group

### Attributes

actor[R]
name[R]

### Public Class Methods

new(registry, klass, options = {}) click to toggle source

    # File lib/celluloid/supervision_group.rb, line 115
    def initialize(registry, klass, options = {})
      @registry = registry
      @klass = klass

      # Stringify keys :/
      options = options.inject({}) { |h,(k,v)| h[k.to_s] = v; h }

      @name = options['as']
      @block = options['block']
      @args = options['args'] ? Array(options['args']) : []
      @method = options['method'] || 'new_link'
      @pool = @method == 'pool_link'
      @pool_size = options['size'] if @pool

      start
    end

### Public Instance Methods

cleanup() click to toggle source

    # File lib/celluloid/supervision_group.rb, line 158
    def cleanup
      @registry.delete(@name) if @name
    end

restart() click to toggle source

    # File lib/celluloid/supervision_group.rb, line 145
    def restart
      @actor = nil
      cleanup

      start
    end

start() click to toggle source

    # File lib/celluloid/supervision_group.rb, line 133
    def start
      # when it is a pool, then we don't splat the args
      # and we need to extract the pool size if set
      if @pool
        options = {:args => @args}
        options[:size] = @pool_size if @pool_size
        @args = [options]
      end
      @actor = @klass.send(@method, *@args, &@block)
      @registry[@name] = @actor if @name
    end

terminate() click to toggle source

    # File lib/celluloid/supervision_group.rb, line 152
    def terminate
      cleanup
      @actor.terminate if @actor
    rescue DeadActorError
    end