bool Parser::GetCmdLineIncludeFiles(const CC_ARRAY<CC_STRING>& ifiles, size_t np) { if( ifiles.size() == 0) return true; CC_STRING path; bool in_compiler_dir; for(size_t i = 0; i < ifiles.size(); i++) { if(!rtc->get_include_file_path(ifiles[i], CC_STRING(""), true, false, path, &in_compiler_dir)) { errmsg.Format("Can not find include file \"%s\"", ifiles[i].c_str()); return false; } RealFile *file; file = new RealFile; file->SetFileName(path); if( ! file->Open() ) { errmsg.Format("Can not open include file \"%s\"", ifiles[i].c_str()); return false; } PushIncludedFile(file, NULL, np, in_compiler_dir, conditionals.size()); if( ! RunEngine(1) ) return false; if(has_dep_file() && ! in_compiler_dir) AddDependency(" ", path.c_str()); } return true; }
int32_t main() { DWORD dwThread; HANDLE iocp; uint32_t n; uint32_t i = 0; //getchar(); init_wpacket_pool(10000000); init_rpacket_pool(500000); buffer_init_maxbuffer_size(2000); buffer_init_64(2000); init_clients(); InitNetSystem(); iocp = CreateNetEngine(1); CreateThread(NULL,0,Listen,&iocp,0,&dwThread); tick = GetTickCount(); while(1) { RunEngine(iocp,15); /*now = GetTickCount(); if(now - tick > 1000) { printf("recv:%u,send:%u,s_req:%u,pool_size:%u,bf:%u,sp:%u,iocp:%u\n",packet_recv,packet_send,send_request,wpacket_pool_size(),bf_count,s_p,iocp_count); tick = now; packet_recv = 0; packet_send = 0; send_request = 0; s_p = 0; iocp_count = 0; } if(now - last_send_tick > 50) { //心跳,每50ms集中发一次包 last_send_tick = now; for(i=0; i < MAX_CLIENT; ++i) { if(clients[i]) { ++send_request; connection_send(clients[i],0,0); } } }*/ } return 0; }
void EditorApplication::InitApplication() { EditorMainWindow* mainWindow = GetMainWindow(); Q_ASSERT(mainWindow != nullptr); // Get the HWND of the panel if (!m_editorEngineProxy.InitializeEngine(mainWindow->GetSceneViewWindowHandle())) { return; } emit EngineInitFinished(); QThread* engineThread = new QThread(); m_editorEngineProxy.moveToThread(engineThread); connect(engineThread, SIGNAL(started()), &m_editorEngineProxy, SLOT(RunEngine())); connect(engineThread, SIGNAL(finished()), engineThread, SLOT(deleteLater())); engineThread->start(); }
/* Parse the input file and update the global symbol table and macro table, * output the stripped file contents to devices if OUTFILE is not nil. * * Returns a pointer to the error messages on failure, or nil on success. */ bool Parser::DoFile(InternalTables *intab, size_t num_preprocessors, File *infile, ParserContext *ctx) { bool ignored; FILE *out_fp; bool retval = false; CC_STRING bak_fname, out_fname; struct stat stb; struct utimbuf utb; if(ctx) { ignored = ctx->check_ignore(infile->name); if( ignored && ! has_dep_file() ) return true; } else ignored = false; if( stat(infile->name, &stb) == 0 ) { utb.actime = stb.st_atime; utb.modtime = stb.st_mtime; } if( ! infile->Open() ) { errmsg.Format("Cannot open \"%s\" for reading\n"); return false; } out_fp = NULL; if(ctx != NULL && ctx->outfile != ParserContext::OF_NULL ) { if( ctx->outfile == ParserContext::OF_STDOUT ) out_fp = stdout; else { #if SANITY_CHECK assert( ! ctx->baksuffix.isnull() ); #endif if( ctx->baksuffix[0] != ParserContext::MAGIC_CHAR ) bak_fname = infile->name + ctx->baksuffix; else out_fname = infile->name; int fd; char tmp_outfile[32]; strcpy(tmp_outfile, "@cl@-XXXXXX"); fd = mkstemp(tmp_outfile); if( fd < 0 ) { errmsg.Format("Cannot open \"%s\" for writing\n", tmp_outfile); infile->Close(); return false; } out_fp = fdopen(fd, "wb"); out_fname = tmp_outfile; } } if(ctx == NULL) memset(writers, 0, sizeof(writers)); else { writers[VCH_CL] = NULL; if(!ctx->of_array[VCH_DEP].isnull()) writers[VCH_DEP] = gvar_file_writers[VCH_DEP]; if(!ctx->of_array[VCH_CV].isnull()) writers[VCH_CV] = gvar_file_writers[VCH_CV]; } if( num_preprocessors >= COUNT_OF(Parser::preprocessors) ) num_preprocessors = COUNT_OF(Parser::preprocessors); Reset(intab, num_preprocessors, ctx); if(has_dep_file()) AddDependency("", infile->name); PushIncludedFile(infile, out_fp, COUNT_OF(Parser::preprocessors), false, conditionals.size()); if(ctx != NULL) { GetCmdLineIncludeFiles(ctx->imacro_files, 2); GetCmdLineIncludeFiles(ctx->include_files, COUNT_OF(preprocessors)); } if( ! RunEngine(0) ) goto error; SaveDepInfo(deptext); if( conditionals.size() != 0 ) errmsg = "Unmatched #if"; else retval = true; error: if(!retval) { if(included_files.size() > 0) { CC_STRING tmp; tmp.Format("%s:%u: %s\n%s\n", GetCurrentFileName().c_str(), GetCurrentLineNumber(), pline.from.c_str(), GetError()); errmsg = tmp; } #if 0 IncludedFile *ilevel; while(included_files.size() > 0) { ilevel = PopIncludedFile(); if(infile != ilevel->ifile) delete ilevel; } #endif } if(out_fp != NULL && out_fp != stdout) fclose(out_fp); if( retval && ctx != NULL && ! ignored ) { CC_STRING semname; sem_t *sem; semname = MakeSemaName(infile->name); sem = sem_open(semname.c_str(), O_CREAT, 0666, 1); sem_wait(sem); if( ! bak_fname.isnull() ) rename(infile->name, bak_fname); if( ! out_fname.isnull() ) { rename(out_fname, infile->name); utime(infile->name.c_str(), &utb); } sem_post(sem); sem_unlink(semname.c_str()); } else if( ! out_fname.isnull() ) unlink(out_fname.c_str()); return retval; }