class Concurrent::Supervisor

def add_worker(worker, opts = {})

def add_worker(worker, opts = {})
  return nil if worker.nil? || ! behaves_as_worker?(worker)
  @mutex.synchronize {
    restart = opts[:restart] || :permanent
    type = opts[:type] || (worker.is_a?(Supervisor) ? :supervisor : nil) || :worker
    raise ArgumentError.new(":#{restart} is not a valid restart option") unless CHILD_RESTART_OPTIONS.include?(restart)
    raise ArgumentError.new(":#{type} is not a valid child type") unless CHILD_TYPES.include?(type)
    context = WorkerContext.new(worker, type, restart)
    @workers << context
    @count.add(context)
    worker.run if @running
    context.object_id
  }
end