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


C++ Extension::clone方法代码示例

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


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

示例1: mainLoop

int ManagerClass::mainLoop()
{
    int retval ;
    pid_t pid = 0 ;
    bool execed = false;
    /*
     * Loop until there's no monitored process left. 
     */
    while_begin:
    while (process_count > 0)	{
	/* wait for next call */
	SystemCall theCall ;
#ifdef MEASURE_TIME
	struct tms start_tms ;
	times(&start_tms) ;
#endif
	retval = arch->waitForCall(&pid, &theCall);
	
#ifdef MEASURE_TIME
	struct tms end_tms ;
	times(&end_tms) ;
#endif

	if (NEXTCALL_ERROR == retval) 
	    continue ;

	MonitoredProc *supObj = monitoringTable.lookUp(pid) ;
	if (0 == supObj) {
	    cerr << "ManagerClass: No record of process!" << endl ;
	    continue ;
	}
	
	execed = false;
	switch (retval) {
	case NEXTCALL_EXITED:
	    process_count -- ;
	    // set the exit flag, so that destructor of MP won't kill it again
	    supObj->setExitFlag();
	    monitoringTable.remove(pid) ;
	    goto while_begin ;
	    break ;
	case NEXTCALL_CREATED:
	    /* alloc a new monitoring object for new process */
	    /* ASSUMPTION: new pid is returned by return value */
	    if (!theCall.isEntry()) {
		int errnum ;
		long childpid = arch->getReturnVal(pid, &errnum) ;
		MonitoredProc *childObj = new MonitoredProc(this) ;
		if (0 == childObj) {
		    cerr <<"ManagerClass: Cannot alloc MonitoredProc!" << endl;
		    arch->terminateProc(childpid) ;
		    return -1 ;
		}
		childObj->pid(childpid) ;
		childObj->programName(supObj->programName()) ;
		childObj->mapFileName(supObj->mapFileName()) ;
		supObj->resetExtensionList() ;
		Extension *pExtension ;
		while ((pExtension=supObj->getNextExtension()) != 0) {
		    Extension *ext = pExtension->clone() ;
		    childObj->insertExtension(ext) ;
		}
	
		monitoringTable.insert(childpid, childObj) ;
		process_count ++ ;
	    }
	    break ;
	case NEXTCALL_EXECED:
	    execed = true;
	    break ;
	default: 
	    break ;
	}

#ifdef MEASURE_TIME
	long scno = theCall.scno() ;
	user_time[scno] += end_tms.tms_utime - start_tms.tms_utime ;
	sys_time[scno] += end_tms.tms_stime - start_tms.tms_stime ;
	call_count[scno] ++ ;
#endif
	/* deliver this event to the Extensions */
	/* The Extensions are arranged as layers, i.e., the first Extension at the 
	   entry point is the last Extension at the exit point */
	

	if (switch_on_exec) {
	    if (execed)
		if (theCall.isEntry()) {
		    CString exec(theCall.getArgRep(0)) ;
		    supObj->programTemp(exec.get().c_str()) ;
		} 
	}
	    
	supObj->setCurCall(&theCall) ;
	Extension *pExtension ;
	supObj->resetExtensionList() ;
	while (true) {
	    if (theCall.isEntry())
		pExtension = supObj->getNextExtension() ;
	    else 
//.........这里部分代码省略.........
开发者ID:bhushanjain,项目名称:cse508,代码行数:101,代码来源:ManagerClass.cpp


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