当前位置: 首页>>代码示例>>C++>>正文


C++ Thread::RunAfter方法代码示例

本文整理汇总了C++中Thread::RunAfter方法的典型用法代码示例。如果您正苦于以下问题:C++ Thread::RunAfter方法的具体用法?C++ Thread::RunAfter怎么用?C++ Thread::RunAfter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Thread的用法示例。


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

示例1: OpenStateMachine

void MDT::OpenStateMachine(ThreadLocalData *tld)
{
	Processor *p = tld->p;
	Message *msg = tld->m;
	FileObject *obj = (FileObject *)msg->req;
	Thread *t = tld->t;

	switch (tld->state) {
	case mdt_OpenFileState:
		/* It will take 5ms to open/create a new file. Very simple... */
		t->RunAfter(params.io.OpenTicks + SignRand(params.io.OpenTicks / 10)); 
		tld->state = mdt_OpenCompleteState;
		break;
	case mdt_OpenCompleteState:
		Print(NOW "%s Finished OPEN for [email protected]%llu.\n",
			now, name, obj->GetId());
		msg->SetLength(1024);
		Send(msg);
		p->TaskCompletion(tld);
		msg->phase = RPC_PHASE_COMPLETE;
		break;
	}
}
开发者ID:yingjinqian,项目名称:Lustre-Simulator,代码行数:23,代码来源:mdt.cpp

示例2: OneRun

void PIOS:: OneRun(run_arg *args)
{
	Thread *t;
	ThreadLocalData *tld;

	args->fs = new FileSystem;
	t = new Thread;
	tld = new ThreadLocalData;
	memset(tld, 0, sizeof(*tld));
	tld->v = args;
	tld->t = t;

	Event::SetClock(0);

	args->fs->Start();
	t->CreateThread(do_one_run, tld);
	t->RunAfter(1);

	Event::Schedule();
	
	delete args->fs;
	delete tld;
	delete t;
}
开发者ID:yingjinqian,项目名称:Lustre-Simulator,代码行数:24,代码来源:pios.cpp

示例3: do_one_run

void PIOS::do_one_run(void *data)
{
	ThreadLocalData *tld = (ThreadLocalData *) data;
	run_arg *args = (run_arg *)tld->v;
	
	switch (tld->state) {
	case pios_RunOneStartState: {
		int i;

		args->startime = Event::Clock();
		Print(NOW "Start run: T %lu N %llu C %llu S %llu O %llu\n",
			args->startime, args->threadcount, args->regioncount,
			args->chunksize, args->regionsize, args->offset);

		/* Setup stream */
		args->streams = new pios_stream [args->regioncount];
		for (i = 0; i < args->regioncount; i++) {
			if (args->fpp) {
				args->streams[i].fid = i;
				args->streams[i].offset = args->offset;
				args->streams[i].max_offset = args->offset + args->regionsize;
				args->num_open_files++;
			} else {
				args->streams[i].fid = 0;
				args->streams[i].offset = args->offset * i;
				args->streams[i].max_offset = args->offset * i + args->regionsize;
			}
			args->streams[i].iotime = 0;
		}

		/* Setup pios thread data */
		args->ptds = new pios_thdata [args->threadcount];
		args->tlds = new ThreadLocalData [args->threadcount];

		memset(args->ptds, 0, sizeof(pios_thdata) * args->threadcount);
		memset(args->tlds, 0, sizeof(ThreadLocalData) * args->threadcount);
		for (i = 0; i < args->threadcount; i++) {
			Thread *t;

			t = new Thread;

			args->ptds[i].parent = tld->t;
			args->ptds[i].args = args;
			args->ptds[i].io.cmd = WRITE;
			args->ptds[i].io.count = 0;
			args->ptds[i].io.fid = 0;
			args->ptds[i].io.off = 0;
			args->ptds[i].io.waiter = t;
			args->ptds[i].io.left = 0;
			args->ptds[i].io.parent = NULL;
			args->ptds[i].io.ref = 0;

			args->tlds[i].t = t;
			args->tlds[i].id = i;
			args->tlds[i].f = do_one_thread;
			args->tlds[i].v = &args->ptds[i];
			args->tlds[i].flags |= TLD_CTX_SWITCH;
			t->CreateThread(do_one_thread, &args->tlds[i]);

			t->RunAfter(/*Event::Rand(args->threadcount * 10)*/1);
		}
		tld->state = pios_RunOneAllFinishState;
		break;
	}
	case pios_RunOneAllFinishState:
		args->iotime = Event::Clock() - args->startime;
		print_stats(args);
	case pios_RunOneLastState:
		/* cleanup all resource. */
		delete [] args->streams;
		delete [] args->ptds;
		delete [] args->tlds;
		break;
	}
}
开发者ID:yingjinqian,项目名称:Lustre-Simulator,代码行数:75,代码来源:pios.cpp


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