Spawn new actors if needed.
423496
def spawn_actors(self, monitor):
        '''
        '''
        to_spawn = monitor.cfg.workers - len(self.managed_actors)
        if monitor.cfg.workers and to_spawn > 0:
            for _ in range(to_spawn):
                monitor.spawn()
376229
def recruit_participants(self, n=1, exp=None):
        """"""
        for i in xrange(n):
            newcomer = exp.agent_type()
            exp.newcomer_arrival_trigger(newcomer)
482628
def generate_child(actor, prototype, target)
    child = super(actor, prototype)
    child.vector.pitch = Utility.find_angle(actor.location, target.location) + child.vector.pitch
    child
  end
15705
def load_actors
      # Load agent's configured actors
      actors = (@options[:actors] || []).clone
      Log.info("[setup] Agent #{@identity} with actors #{actors.inspect}")
      actors_dirs = AgentConfig.actors_dirs
      actors_dirs.each do |dir|
        Dir["#{dir}/*.rb"].each do |file|
          actor = File.basename(file, ".rb")
          next if actors && !actors.include?(actor)
          Log.info("[setup] Loading actor #{file}")
          require file
          actors.delete(actor)
        end
      end
      ErrorTracker.log(self, "Actors #{actors.inspect} not found in #{actors_dirs.inspect}") unless actors.empty?

      # Perform agent-specific initialization including actor creation and registration
      if (init_file = AgentConfig.init_file)
        Log.info("[setup] Initializing agent from #{init_file}")
        instance_eval(File.read(init_file), init_file)
      else
        ErrorTracker.log(self, "No agent init.rb file found in init directory of #{AgentConfig.root_dir.inspect}")
      end
      true
    end
533995
def push_script(self, scriptable, script, callback=None):
        """"""
        if script in self.threads:
            self.threads[script].finish()
        thread = Thread(self.run_script(scriptable, script),
                                      scriptable, callback)
        self.new_threads[script] = thread
        return thread
811014
def spawn_actor(self, factory, name=None):
        
        if name and '/' in name:  # pragma: no cover
            raise TypeError("Actor names cannot contain slashes")
        if not self._children:
            self._children = {}
        uri = self.uri / name if name else None
        if name:
            if name.startswith('$'):
                raise ValueError("Unable to spawn actor at path %s; name cannot start with '$', it is reserved for auto-generated names" % (uri.path,))
            if name in self._children:
                raise NameConflict("Unable to spawn actor at path %s; actor %r already sits there" % (uri.path, self._children[name]))
        if not uri:
            name = self._generate_name(factory)
            uri = self.uri / name
        assert name not in self._children  # XXX: ordering??
        child = self._children[name] = Cell.spawn(parent_actor=self.ref, factory=factory, uri=uri, node=self.node).ref
        return child
1219822
public void schedulePendingAdds() {
        ArrayList<Actor> newOnes = new ArrayList<>();
        Actor a;
        while ( (a=toAdd.poll()) != null ) {
            newOnes.add(a);
        }
        if ( newOnes.size() > 0 ) {
            Actor newQueue[] = new Actor[newOnes.size()+actors.length];
            System.arraycopy(actors,0,newQueue,0,actors.length);
            for (int i = 0; i < newOnes.size(); i++) {
                Actor actor = newOnes.get(i);
                newQueue[actors.length+i] = actor;
            }
            actors = newQueue;
        }

    }
959095
def grow(self):
        ""
        t = self.worker_factory(self)
        t.start()
        self._size += 1
888488
function spawn() {
    startInterval();
    var args = Array.prototype.slice.call(arguments);
    if (currentCount < limitCount) {
        currentCount++;
        if (monitorCallback) {
            monitorCallback("start", remainedTasks);
        }
        return new Promise(function (resolved) {
            var process = originalSpawn.apply(null, args);
            process.on("close", function (code) {
                if (monitorCallback) {
                    monitorCallback("close", remainedTasks, code);
                }
                currentCount--;
                if (currentCount === 0 && remainedTasks.length === 0) {
                    callWaitAllCallbacks();
                }
            });
            resolved(process);
        });
    } else {
        var id = taskId++;
        remainedTasks.push([args, id]);
        if (monitorCallback) {
            monitorCallback("added", remainedTasks);
        }
        return new Promise(function (resolved) {
            remainedTaskCallbacks[id] = resolved;
        });
    }
}
180648
function loadActors (fount, actors) {
  let result

  function addActor (acc, instance) {
    let factory = isFunction(instance.state)
      ? instance.state : () => clone(instance.state)
    processHandles(instance)
    acc[ instance.actor.type ] = {
      factory: factory,
      metadata: instance
    }
    return acc
  }

  function onActors (list) {
    function onInstances (instances) {
      return instances.reduce(addActor, {})
    }

    let modules = filter(list)
    let promises = modules.map((modulePath) => {
      let actorFn = loadModule(modulePath)
      return fount.inject(actorFn)
    })

    return Promise
      .all(promises)
      .then(onInstances)
  }

  if (isString(actors)) {
    let filePath = actors
    if (!fs.existsSync(filePath)) {
      filePath = path.resolve(process.cwd(), filePath)
    }
    return getActors(filePath)
      .then(onActors)
  } else if (Array.isArray(actors)) {
    result = actors.reduce((acc, instance) => {
      addActor(acc, instance)
      return acc
    }, {})
    return Promise.resolve(result)
  } else if (isObject(actors)) {
    let keys = Object.keys(actors)
    result = keys.reduce((acc, key) => {
      let instance = actors[ key ]
      addActor(acc, instance)
      return acc
    }, {})
    return Promise.resolve(result)
  } else if (isFunction(actors)) {
    result = actors()
    if (!result.then) {
      result = Promise.resolve(result)
    }
    return result.then(function (list) {
      return list.reduce((acc, instance) => {
        addActor(acc, instance)
        return Promise.resolve(acc)
      }, {})
    })
  }
}
576178
def grow(self, amount):
        """"""
        if self.max > 0:
            budget = max(self.max - len(self._threads), 0)
        else:
            # self.max <= 0 indicates no maximum
            budget = float('inf')

        n_new = min(amount, budget)

        workers = [self._spawn_worker() for i in range(n_new)]
        while not all(worker.ready for worker in workers):
            time.sleep(.1)
        self._threads.extend(workers)
1238791
def add(self, actors):
        
        if utils.isSequence(actors):
            for a in actors:
                if a not in self.actors:
                    self.actors.append(a)
            return None
        else:
            self.actors.append(actors)
            return actors
336648
def actors(context):
    """"""
    fritz = context.obj
    fritz.login()

    for actor in fritz.get_actors():
        click.echo("{} ({} {}; AIN {} )".format(
            actor.name,
            actor.manufacturer,
            actor.productname,
            actor.actor_id,
        ))
        if actor.has_temperature:
            click.echo("Temp: act {} target {}; battery (low): {}".format(
                actor.temperature,
                actor.target_temperature,
                actor.battery_low,
            ))

            click.echo("Temp (via get): act {} target {}".format(
                actor.get_temperature(),
                actor.get_target_temperature(),
            ))
603523
def create(self):
        """"""
        required_nodes = self._get_required_nodes()
        self.lb_attrs = self.consul.create_lb(
                self.instance_name,
                protocol=self.protocol,
                port=self.port,
                nodes=required_nodes,
                node_port=str(self.backend_port),
                algorithm=getattr(self, 'algorithm', None)
                )
798060
function spawn() {
  if(this.ps && this.ps.connected) return;
  this.ps = fork(
    runner, [], {execPath: path.basename(process.execPath)});
  this.ps.send({event: 'loglevel', level: log.level()});
}
559184
function(actor, target, vars) {

		var a = {
			name: actor.get('definite'),
			gender: actor.gender
		};

		var t = {};
		if (target) {
			t.name = target.get('definite');
			t.gender = target.get('gender');
		} else {
			t.name = 'NULL';
			t.gender = 0;
		}

		var pronouns = {
			sub:  ['it', 'he', 'she'],
			obj:  ['it', 'him', 'her'],
			pos:  ['its', 'his', 'her'],
			ref:  ['itself', 'himself', 'herself'],
			hers: ['its', 'his', 'hers']
		};

		Object.each(pronouns, function(v,k) {
			a[k] = v[a.gender] || v[0];
			if (target) { t[k] = v[t.gender] || v[0]; }
		});

		//Replacements: what the actor sees and what the target sees.
		var actor_tags = {
			'You'      : ['You',      a.name],
			"yourself" : ["yourself", a.ref],
			"your"     : ["your",     a.pos],
			'you'      : ['you',      a.sub],
			'thee'     : ['you',      a.obj],
			"yours"    : ["yours",    a.hers],
			"Your"     : ["Your",     a.name+"'s"],
			'has'      : ['have',     'has'],
			'is'       : ['are',      'is']
		};

		var target_tags = {
			'Name'     : ['You',      t.name],
			'They'     : ['You',      t.name],
			'Name'     : ['you',      t.name],
			'they'     : ['you',      t.sub],
			'them'     : ['you',      t.obj],
			"theirs"   : ["yours",    t.hers],
			"their"    : ["your",     t.pos],
			"Their"    : ["your",     t.name+"'s"],
			"themself" : ["yourself", t.ref],
			'HAS'      : ['have',     'has'],
			'IS'       : ['are',      'is']
		};

		var actor_suffixes = {
			's'        : ['', 's'],
			'es'       : ['', 'es'],
			'ies'      : ['y', 'ies'],
			"'s"       : ["'re'", "'s"]
		};

		var target_suffixes = {
			'S'        : ['', 's'],
			'ES'       : ['', 'es'],
			'IES'      : ['y', 'ies'],
			"'S"       : ["'re", "'s"]
		};

		var str = this, str_actor = this, str_target=this, str_others=this;

		Object.each(actor_suffixes, function(replace, tag) {
			var tag = new RegExp('%'+tag+'(\\s?)', 'g');
			if (!str.match(tag)) { return; }
			str_actor  = str_actor.replace(tag, replace[0]+"$1");
			if (target) {
				str_target = str_target.replace(tag, replace[1]+"$1");
			}
			str_others = str_others.replace(tag, replace[1]+"$1");
		});

		Object.each(actor_tags, function(replace, tag) {
			var tag = new RegExp('%'+tag+'(\\s?)', 'g');
			if (!str.match(tag)) { return; }
			str_actor  = str_actor.replace(tag, replace[0]+"$1");
			if (target) {
				str_target = str_target.replace(tag, replace[1]+"$1");
			}
			str_others = str_others.replace(tag, replace[1]+"$1");
		});

		//No need to waste time processing target tags if there's no target.
		if (target) {

			Object.each(target_suffixes, function(replace, tag) {
				var tag = new RegExp('%'+tag+'(\\s?)', 'g');
				if (!str.match(tag)) { return; }
				str_actor  = str_actor.replace(tag, replace[1]+"$1");
				if (target) {
					str_target = str_target.replace(tag, replace[0]+"$1");
				}
				str_others = str_others.replace(tag, replace[1]+"$1");
			});

			Object.each(target_tags, function(replace, tag) {
				var tag = new RegExp('%'+tag+'(\\s?)', 'g');
				if (!str.match(tag)) { return; }
				str_actor  = str_actor.replace(tag, replace[1]+"$1");
				if (target) {
					str_target = str_target.replace(tag, replace[0]+"$1");
				}
				str_others = str_others.replace(tag, replace[1]+"$1");
			});

		} else {
			str_target = str_others;
		}

		strs = [str_actor, str_target, str_others];

		//Auto-capitaliztion
		strs.each(function(str, i) {
			var matches = str.match(/[\.\?!]\s+[a-z]/);
			if (!matches) { return; }
			matches.each(function(m) {
				strs[i] = str.replace(m, m.toUpperCase());
			});
		});
	
		return strs;

	}
662859
def new_cast_status(self, cast_status):
        """"""
        casts = self._casts
        group_members = self._mz.members
        for member_uuid in group_members:
            if member_uuid not in casts:
                continue
            for listener in list(casts[member_uuid]['listeners']):
                listener.multizone_new_cast_status(
                    self._group_uuid, cast_status)