• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ spawn函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中spawn函数的典型用法代码示例。如果您正苦于以下问题:C++ spawn函数的具体用法?C++ spawn怎么用?C++ spawn使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了spawn函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: spawn_monster

void spawn_monster() {
    auto monster = spawn().lock();

    monster->act = monster_act;

    while(1) {
        AxialPosition p;

        int x = rnd(0, (int)game.map->width);
        int y = rnd(0, (int)game.map->height);

        game.map->from_data_coord(x, y, p);

        if(game.map->empty(p)) {
            monster->position = p;
            break;
        }
    }

    monster->energy_gain = rnd(100, 300);

    add_message("Added monster with %i energy gain", monster->energy_gain);
}
开发者ID:discoloda,项目名称:Projects,代码行数:23,代码来源:main.cpp


示例2: while

void Emitter::update(float dt)
{
    accumulated_time_ += dt;
    while (accumulated_time_ >= spawn_rate_)
    {
        accumulated_time_ -= spawn_rate_;
        instances_.push_back(spawn());
    }

    size_t number = instances_.size();
    for (size_t i = 0; i < number; i++)
    {
        instances_[i]->update(dt);
        if (instances_[i]->done())
        {
            delete instances_[i];
            std::swap(instances_[i],instances_[number-1]);
            number--;
        }
    }

    instances_.erase(instances_.begin() + number,instances_.end());
}
开发者ID:nlguillemot,项目名称:tsukino,代码行数:23,代码来源:emitter.cpp


示例3: runorraise

void
runorraise(const Arg *arg) {
    const char **app = arg->v;
    Arg a = { .ui = ~0 };
    Monitor *mon;
    Client *c;
    XClassHint hint = { NULL, NULL };

/* Tries to find the client */
  for (mon = mons; mon; mon = mon->next) {
    for (c = mon->clients; c; c = c->next) {
      XGetClassHint(dpy, c->win, &hint);
      if (hint.res_class && strcmp(app[2], hint.res_class) == 0) {
        a.ui = c->tags;
        view(&a);
        focus(c);
        return;
      }
    }
  }
  /* Client not found: spawn it */
  spawn(arg);
} 
开发者ID:dougpiston,项目名称:dwm,代码行数:23,代码来源:runorraise.c


示例4: make_bubbles

void make_bubbles()
{
	gedict_t       *bubble;

	bubble = spawn();
	setmodel( bubble, "progs/s_bubble.spr" );
	setorigin( bubble, PASSVEC3( self->s.v.origin ) );
	bubble->s.v.movetype = MOVETYPE_NOCLIP;
	bubble->s.v.solid = SOLID_NOT;

	SetVector( bubble->s.v.velocity, 0, 0, 15 );
	bubble->s.v.nextthink = g_globalvars.time + 0.5;
	bubble->think = ( func_t ) bubble_bob;
	bubble->touch = ( func_t ) bubble_remove;
	bubble->classname = "bubble";
	bubble->s.v.frame = 0;
	bubble->cnt = 0;

	setsize( bubble, -8, -8, -8, 8, 8, 8 );

	self->s.v.nextthink = g_globalvars.time + g_random() + 0.5;
	self->think = ( func_t ) make_bubbles;
}
开发者ID:deurk,项目名称:ktx,代码行数:23,代码来源:misc.c


示例5: spawn_tdeath

void spawn_tdeath( vec3_t org, gedict_t * death_owner )
{

	gedict_t       *death;

	death = spawn();
	death->s.v.classname = "teledeath";
	death->s.v.movetype = MOVETYPE_NONE;
	death->s.v.solid = SOLID_TRIGGER;
	SetVector( death->s.v.angles, 0, 0, 0 );

	setsize( death, death_owner->s.v.mins[0] - 1, death_owner->s.v.mins[1] - 1,
		      death_owner->s.v.mins[2] - 1, death_owner->s.v.maxs[0] + 1,
		      death_owner->s.v.maxs[1] + 1, death_owner->s.v.maxs[2] + 1 );
	setorigin( death, PASSVEC3( org ) );

	death->s.v.touch = ( func_t ) tdeath_touch;
	death->s.v.nextthink = g_globalvars.time + 0.2;
	death->s.v.think = ( func_t ) SUB_Remove;
	death->s.v.owner = EDICT_TO_PROG( death_owner );

	g_globalvars.force_retouch = 2;	// make sure even still objects get hit
}
开发者ID:angeld29,项目名称:qwprogs-qvm,代码行数:23,代码来源:triggers.c


示例6: do_stop

/*
 * This function simply stops the service p.
 * @param s A Service_T object
 * @param flag TRUE if the monitoring should be disabled or FALSE if monitoring should continue (when stop is part of restart)
 * @return TRUE if the service was stopped otherwise FALSE
 */
static int do_stop(Service_T s, int flag) {
        int rv = TRUE;
        ASSERT(s);
        if (s->depend_visited)
                return rv;
        s->depend_visited = TRUE;
        if (s->stop) {
                if (s->type != TYPE_PROCESS || Util_isProcessRunning(s, FALSE)) {
                        LogInfo("'%s' stop: %s\n", s->name, s->stop->arg[0]);
                        spawn(s, s->stop, NULL);
                        if (s->type == TYPE_PROCESS && (wait_process(s, Process_Stopped) != Process_Stopped)) // Only wait for process service types stop
                                rv = FALSE;
                }
        } else {
                LogDebug("'%s' stop skipped -- method not defined\n", s->name);
        }
        if (flag)
                Util_monitorUnset(s);
        else
                Util_resetInfo(s);
        
        return rv;
}
开发者ID:plfrancis,项目名称:clearwater-monit,代码行数:29,代码来源:control.c


示例7: agent_spawn

void
agent_spawn (bool opt_verbose)
{
  // start agent if needed (sfsagent -c)
  if (!isagentrunning ()) {
    if (opt_verbose)
      warn << "No existing agent found; spawning a new one...\n";
    str sa = find_program ("sfsagent");
    vec<char *> av;

    av.push_back (const_cast<char *> (sa.cstr ()));
    av.push_back ("-c");
    av.push_back (NULL);
    pid_t pid = spawn (av[0], av.base ());
    if (waitpid (pid, NULL, 0) < 0)
      fatal << "Could not spawn a new SFS agent: " <<
	strerror (errno) << "\n";
  }
  else {
    if (opt_verbose)
      warn << "Contacting existing agent...\n";
  }
}
开发者ID:dougc333,项目名称:sfs_eventdrivenc--templatelibrary,代码行数:23,代码来源:agentmisc.C


示例8: mainloop

/** WMFS main loop.
 */
static void
mainloop(void)
{
     XEvent ev;
     pthread_t th_status;

     if (estatus && conf.status_timing == 0)
          conf.status_pid = spawn(conf.status_path);
     else if (estatus && pthread_create(&th_status, NULL, thread_status, NULL) != 0) {
          warnx("pthread_create");
          estatus = False;
     }

     while (!exiting && !XNextEvent(dpy, &ev)) {
          getevent(ev);
          wait_childs_and_status();
     }

     if (estatus)
          pthread_join(th_status, NULL);

     return;
}
开发者ID:wavebeem,项目名称:wmfs,代码行数:25,代码来源:wmfs.c


示例9: HoloDood

// spawn the actual holo
void HoloDood ( )
{
	gedict_t *holo;
	vec3_t vtemp;

	sound( self, 1, "weapons/railgr1a.wav", 0.6, 1 );
	holo = spawn(  );
	holo->s.v.owner = EDICT_TO_PROG( self );
	vtemp[0] =
		self->s.v.origin[0];
	vtemp[1] =
		self->s.v.origin[1];
	vtemp[2] =
		self->s.v.origin[2] + 24;
	setorigin( holo, PASSVEC3( vtemp ) );
	holo->s.v.angles[1] = self->s.v.angles[1];
	holo->s.v.angles[0] = self->s.v.angles[0];
	holo->s.v.skin = self->s.v.skin;
	holo->s.v.frame = self->s.v.frame;
	holo->s.v.colormap = self->s.v.colormap;
	holo->s.v.flags = 256;
	holo->s.v.solid = SOLID_TRIGGER;
	holo->s.v.effects = EF_DIMLIGHT;
	holo->s.v.movetype = MOVETYPE_TOSS;
	setmodel( holo, "progs/player.mdl" );
	setsize( holo, -16, -16, -24, 16, 16, 32 );
	holo->s.v.classname = "holo";
	holo->playerclass = 0;
	holo->s.v.nextthink = g_globalvars.time + 1;
	holo->s.v.think = ( func_t ) HoloHumm;
	trap_WriteByte( MSG_MULTICAST, SVC_TEMPENTITY );
	trap_WriteByte( MSG_MULTICAST, 11 );
	trap_WriteCoord( MSG_MULTICAST, self->s.v.origin[0] );
	trap_WriteCoord( MSG_MULTICAST, self->s.v.origin[1] );
	trap_WriteCoord( MSG_MULTICAST, self->s.v.origin[2] );
	trap_multicast( PASSVEC3( self->s.v.origin ), 1 );
}
开发者ID:MrPnut,项目名称:QHome,代码行数:38,代码来源:common.c


示例10: run_main

int
run_main (int, ACE_TCHAR *[])
{
  ACE_START_TEST (ACE_TEXT ("MM_Shared_Memory_Test"));

#if !defined (ACE_LACKS_MMAP) && !defined (ACE_DISABLE_MKTEMP)
  ACE_TCHAR temp_file[MAXPATHLEN + 1];

  // Get the temporary directory,
  // The - 24 is for the filename, mm_shared_mem_testXXXXXX
  if (ACE::get_temp_dir (temp_file, MAXPATHLEN - 24) == -1)
    ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("Temporary path too long\n")), -1);

  // Add the filename to the end
  ACE_OS::strcat (temp_file, ACE_TEXT ("mm_shared_mem_testXXXXXX"));

  // Store in the global variable.
  shm_key = temp_file;

  if (ACE_OS::mktemp (shm_key) == 0
      || (ACE_OS::unlink (shm_key) == -1
          && errno == EPERM))
    ACE_ERROR_RETURN ((LM_ERROR,
                       ACE_TEXT ("(%P|%t) %p\n"),
                       shm_key),
                      1);
  spawn ();

#else /* !ACE_LACKS_MMAP */
  ACE_ERROR ((LM_INFO,
              ACE_TEXT ("mmap and mktemp")
              ACE_TEXT ("are required for this test\n")));
#endif /* !ACE_LACKS_MMAP */

  ACE_END_TEST;
  return 0;
}
开发者ID:suiye223,项目名称:ace-linux,代码行数:37,代码来源:MM_Shared_Memory_Test.cpp


示例11: SpectatorConnect

////////////////
// GlobalParams:
// time
// self
// params
///////////////
void SpectatorConnect()
{
	gedict_t *p;
	int diff = (int)(PROG_TO_EDICT(self->s.v.goalentity) - world);

	if ( !SpecCanConnect( self ) )
	{
		stuffcmd(self, "disconnect\n"); // FIXME: stupid way
		return;
	}

	SpecDecodeLevelParms();

	self->ct = ctSpec;
	self->s.v.classname = "spectator"; // Added this in for kick code
	self->k_accepted = 1; // spectator has no restriction to connect

	for ( p = world; (p = ( match_in_progress == 2 && !cvar("k_ann") ) ? find_spc( p ) : find_client( p )); )
		if ( p != self )  // does't show msg for self
			G_sprint( p, PRINT_HIGH, "Spectator %s entered the game\n", self->s.v.netname  );

	if ( diff < 0 || diff >= MAX_EDICTS ) // something wrong happen - fixing
		self->s.v.goalentity = EDICT_TO_PROG( world );

	VIP_ShowRights( self );
	CheckRate(self, "");

	if ( match_in_progress != 2 ) {
		self->wizard = spawn();
		self->wizard->s.v.classname = "spectator_wizard";
		self->wizard->s.v.think = ( func_t ) wizard_think;
		self->wizard->s.v.nextthink = g_globalvars.time + 0.1;
	}

	// Wait until you do stuffing
	MakeMOTD();
}
开发者ID:devrac,项目名称:ktx,代码行数:43,代码来源:spectate.c


示例12: run

/**
 * Run a script. argv[2] is already NULL.
 */
static int run(char *argv[3], struct in_addr *ip)
{
	int status;
	char *addr = addr; /* for gcc */
	const char *fmt = "%s %s %s" + 3;

	VDBG("%s run %s %s\n", intf, argv[0], argv[1]);

	if (ip) {
		addr = inet_ntoa(*ip);
		setenv("ip", addr, 1);
		fmt -= 3;
	}
	bb_info_msg(fmt, argv[1], intf, addr);

	status = wait4pid(spawn(argv));
	if (status < 0) {
		bb_perror_msg("%s %s %s" + 3, argv[1], intf);
		return -errno;
	}
	if (status != 0)
		bb_error_msg("script %s %s failed, exitcode=%d", argv[0], argv[1], status);
	return status;
}
开发者ID:benjaminlevine,项目名称:Huawei-HG633-Open-Source-Software-Package,代码行数:27,代码来源:zcip.c


示例13: spawn

void CreatureManager::loadSpawns(const std::string& fileName)
{
    if(!isLoaded()) {
        g_logger.warning("creatures aren't loaded yet to load spawns.");
        return;
    }

    if(m_spawnLoaded) {
        g_logger.warning("attempt to reload spawns.");
        return;
    }

    try {
        TiXmlDocument doc;
        doc.Parse(g_resources.readFileContents(fileName).c_str());
        if(doc.Error())
            stdext::throw_exception(stdext::format("cannot load spawns xml file '%s: '%s'", fileName, doc.ErrorDesc()));

        TiXmlElement* root = doc.FirstChildElement();
        if(!root || root->ValueStr() != "spawns")
            stdext::throw_exception("malformed spawns file");

        for(TiXmlElement* node = root->FirstChildElement(); node; node = node->NextSiblingElement()) {
            if(node->ValueTStr() != "spawn")
                stdext::throw_exception("invalid spawn node");

            SpawnPtr spawn(new Spawn);
            spawn->load(node);
            m_spawns.insert(std::make_pair(spawn->getCenterPos(), spawn));
        }
        doc.Clear();
        m_spawnLoaded = true;
    } catch(std::exception& e) {
        g_logger.error(stdext::format("Failed to load '%s': %s", fileName, e.what()));
    }
}
开发者ID:Anastaciaa,项目名称:otclient-1,代码行数:36,代码来源:creatures.cpp


示例14: cvar

gedict_t *ThrowGib( char *gibname, float dm )
{
	gedict_t       *newent;
	int			    k_short_gib = cvar( "k_short_gib" ); // if set - remove faster

	newent = spawn();
	VectorCopy( self->s.v.origin, newent->s.v.origin );
	setmodel( newent, gibname );
	setsize( newent, 0, 0, 0, 0, 0, 0 );
	VelocityForDamage( dm, newent->s.v.velocity );
	newent->s.v.movetype = MOVETYPE_BOUNCE;
	newent->isMissile = true;
	newent->s.v.solid = SOLID_NOT;
	newent->s.v.avelocity[0] = g_random() * 600;
	newent->s.v.avelocity[1] = g_random() * 600;
	newent->s.v.avelocity[2] = g_random() * 600;
	newent->think = ( func_t ) SUB_Remove;
	newent->s.v.ltime = g_globalvars.time;
	newent->s.v.nextthink = g_globalvars.time + ( k_short_gib ? 2 : ( 10 + g_random() * 10 ) );
	newent->s.v.frame = 0;
	newent->s.v.flags = 0;

	return newent;
}
开发者ID:deurk,项目名称:ktx,代码行数:24,代码来源:player.c


示例15: main

int main (int argc, char *argv[]){
	char* arg_list[10] = {};
	/*no argmuments*/
	if(argc <= 1){
	  childParent();
   	  return 0;
	}else if(argc == 2){/*one argument*/
	  spawnOne(argv[1]);
	}else{/*multiple arguments*/
	  int i = 0;
	  while(i<argc){
	    if(i+1==argc){
	      arg_list[i] = NULL;
	    }
	    else{
	      arg_list[i] = argv[i+1];
	    }
	    i++;
	  }
	  spawn (argv[1], arg_list);
	}
	printf("done with main program\n");
	return 0;
}
开发者ID:akendall,项目名称:cs3060-Spring,代码行数:24,代码来源:assn2.c


示例16: udhcp_run_script

/* Call a script with a par file and env vars */
void FAST_FUNC udhcp_run_script(struct dhcp_packet *packet, const char *name)
{
	char **envp, **curr;
	char *argv[3];

	if (client_config.script == NULL)
		return;

	envp = fill_envp(packet);

	/* call script */
	log1("Executing %s", client_config.script);
	argv[0] = (char*) client_config.script;
	argv[1] = (char*) name;
	argv[2] = NULL;
	wait4pid(spawn(argv));

	for (curr = envp; *curr; curr++) {
		log2(" %s", *curr);
		bb_unsetenv(*curr);
		free(*curr);
	}
	free(envp);
}
开发者ID:Cheezzolo123,项目名称:MonteDroid,代码行数:25,代码来源:script.c


示例17: QGraphicsScene

Game::Game()
{
  //  start = new Start();
    scene = new QGraphicsScene();

    player = new Player();
    scene->addItem(player);

  /*  QGraphicsPixmapItem *drum = new QGraphicsPixmapItem();
    drum->setPixmap(QPixmap(":/images/testdrum2.png"));
    drum->setPos(0,143);
    scene->addItem(drum);*/

    player->setFlag(QGraphicsItem::ItemIsFocusable);
    player->setFocus();

    setScene(scene);
    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setFixedSize(768,557);

    scene->setSceneRect(0,0,768,557);
    scene->setBackgroundBrush(QBrush(QPixmap(":/image/bgg6.png")));

    //create the score
    score = new Score();
    scene->addItem(score);

    QTimer * timer = new QTimer();
    QObject::connect(timer,SIGNAL(timeout()),player,SLOT(spawn()));
    timer->start(1200);

    mytimer = new Mytimer();
    scene->addItem(mytimer);

}
开发者ID:jjoe0303,项目名称:Qttest,代码行数:36,代码来源:game.cpp


示例18: memset

void SpawnMgr::spawnEntity(ai::Zone& zone, network::messages::NpcType start, network::messages::NpcType end, int maxAmount) {
	const int offset = start + 1;
	int count[end - offset];
	memset(count, 0, sizeof(count));
	zone.execute([start, end, offset, &count] (const ai::AIPtr& ai) {
		const AICharacter& chr = ai::character_cast<AICharacter>(ai->getCharacter());
		const Npc& npc = chr.getNpc();
		const network::messages::NpcType type = npc.npcType();
		if (type <= start || type >= end)
			return;
		const int index = type - offset;
		++count[index];
	});

	const int size = SDL_arraysize(count);
	for (int i = 0; i < size; ++i) {
		if (count[i] >= maxAmount)
			continue;

		const int needToSpawn = maxAmount - count[i];
		network::messages::NpcType type = static_cast<network::messages::NpcType>(offset + i);
		spawn(zone, type, needToSpawn);
	}
}
开发者ID:mgerhardy,项目名称:engine,代码行数:24,代码来源:SpawnMgr.cpp


示例19: user_k

void user_k( void ) {
	int i;
	int pid;
	char buf[16];

	write( FD_CONSOLE, "User K running\n", 0 );
	write( FD_SIO, "K", 1 );

	for( i = 0; i < 3 ; ++i ) {
		pid = spawn( user_x );
		if( pid < 0 ) {
			write( FD_CONSOLE, "User K spawn() #", 0 );
			pid = itos10( buf, i );
			write( FD_CONSOLE, buf, pid );
			write( FD_CONSOLE, " failed\n", 0 );
		} else {
			sleep( SECONDS_TO_MS(30) );
			write( FD_SIO, "K", 1 );
		}
	}

	write( FD_CONSOLE, "User K exiting\n", 0 );
	exit();
}
开发者ID:robopt,项目名称:systems-programming,代码行数:24,代码来源:user.c


示例20: user_j

void user_j( void ) {
	int i;
	int pid;
	char buf[16];

	write( FD_CONSOLE, "User J running\n", 0 );
	write( FD_SIO, "J", 1 );

	for( i = 0; i < N_PROCS * 2 ; ++i ) {
		pid = spawn( user_y );
		if( pid < 0 ) {
			write( FD_SIO, "j", 1 );
			write( FD_CONSOLE, "User J spawn() #", 0 );
			pid = itos10( buf, i );
			write( FD_CONSOLE, buf, pid );
			write( FD_CONSOLE, " failed\n", 0 );
		} else {
			write( FD_SIO, "J", 1 );
		}
	}

	write( FD_CONSOLE, "User J exiting\n", 0 );
	exit();
}
开发者ID:robopt,项目名称:systems-programming,代码行数:24,代码来源:user.c



注:本文中的spawn函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ spawn_thread函数代码示例发布时间:2022-05-30
下一篇:
C++ spatium函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap