这篇教程C++ store函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中store函数的典型用法代码示例。如果您正苦于以下问题:C++ store函数的具体用法?C++ store怎么用?C++ store使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了store函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: MOZ_ASSERTtemplate<class Super> boolParent<Super>::RecvGetOriginKey(const uint32_t& aRequestId, const nsCString& aOrigin, const bool& aPrivateBrowsing){ MOZ_ASSERT(NS_IsMainThread()); // First, get profile dir. MOZ_ASSERT(NS_IsMainThread()); nsCOMPtr<nsIFile> profileDir; nsresult rv = NS_GetSpecialDirectory(NS_APP_USER_PROFILE_50_DIR, getter_AddRefs(profileDir)); if (NS_WARN_IF(NS_FAILED(rv))) { return false; } // Then over to stream-transport thread to do the actual file io. // Stash a pledge to hold the answer and get an id for this request. nsRefPtr<Pledge<nsCString>> p = new Pledge<nsCString>(); uint32_t id = mOutstandingPledges.Append(*p); nsCOMPtr<nsIEventTarget> sts = do_GetService(NS_STREAMTRANSPORTSERVICE_CONTRACTID); MOZ_ASSERT(sts); nsRefPtr<OriginKeyStore> store(mOriginKeyStore); bool sameProcess = mSameProcess; rv = sts->Dispatch(NewRunnableFrom([id, profileDir, store, sameProcess, aOrigin, aPrivateBrowsing]() -> nsresult { MOZ_ASSERT(!NS_IsMainThread()); store->mOriginKeys.SetProfileDir(profileDir); nsCString result; if (aPrivateBrowsing) { store->mPrivateBrowsingOriginKeys.GetOriginKey(aOrigin, result); } else { store->mOriginKeys.GetOriginKey(aOrigin, result); } // Pass result back to main thread. nsresult rv; rv = NS_DispatchToMainThread(NewRunnableFrom([id, store, sameProcess, result]() -> nsresult { Parent* parent = GccGetSingleton<Super>(); // GetSingleton(); if (!parent) { return NS_OK; } nsRefPtr<Pledge<nsCString>> p = parent->mOutstandingPledges.Remove(id); if (!p) { return NS_ERROR_UNEXPECTED; } p->Resolve(result); return NS_OK; }), NS_DISPATCH_NORMAL); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } return NS_OK; }), NS_DISPATCH_NORMAL); if (NS_WARN_IF(NS_FAILED(rv))) { return false; } p->Then([aRequestId, sameProcess](const nsCString& aKey) mutable { if (!sameProcess) { if (!sIPCServingParent) { return NS_OK; } unused << sIPCServingParent->SendGetOriginKeyResponse(aRequestId, aKey); } else { nsRefPtr<MediaManager> mgr = MediaManager::GetInstance(); if (!mgr) { return NS_OK; } nsRefPtr<Pledge<nsCString>> pledge = mgr->mGetOriginKeyPledges.Remove(aRequestId); if (pledge) { pledge->Resolve(aKey); } } return NS_OK; }); return true;}
开发者ID:haasn,项目名称:gecko-dev,代码行数:86,
示例2: mainintmain(){ IloEnv env; try { NumMatrix cost(env, nbMonths); cost[0]=IloNumArray(env, nbProducts, 110.0, 120.0, 130.0, 110.0, 115.0); cost[1]=IloNumArray(env, nbProducts, 130.0, 130.0, 110.0, 90.0, 115.0); cost[2]=IloNumArray(env, nbProducts, 110.0, 140.0, 130.0, 100.0, 95.0); cost[3]=IloNumArray(env, nbProducts, 120.0, 110.0, 120.0, 120.0, 125.0); cost[4]=IloNumArray(env, nbProducts, 100.0, 120.0, 150.0, 110.0, 105.0); cost[5]=IloNumArray(env, nbProducts, 90.0, 100.0, 140.0, 80.0, 135.0); // Variable definitions IloNumVarArray produce(env, nbMonths, 0, IloInfinity); NumVarMatrix use(env, nbMonths); NumVarMatrix buy(env, nbMonths); NumVarMatrix store(env, nbMonths); IloInt i, p; for (i = 0; i < nbMonths; i++) { use[i] = IloNumVarArray(env, nbProducts, 0, IloInfinity); buy[i] = IloNumVarArray(env, nbProducts, 0, IloInfinity); store[i] = IloNumVarArray(env, nbProducts, 0, 1000); } IloExpr profit(env); IloModel model(env); // For each type of raw oil we must have 500 tons at the end for (p = 0; p < nbProducts; p++) { store[nbMonths-1][p].setBounds(500, 500); } // Constraints on each month for (i = 0; i < nbMonths; i++) { // Not more than 200 tons of vegetable oil can be refined model.add(use[i][v1] + use[i][v2] <= 200); // Not more than 250 tons of non-vegetable oil can be refined model.add(use[i][o1] + use[i][o2] + use[i][o3] <= 250); // Constraints on food composition model.add(3 * produce[i] <= 8.8 * use[i][v1] + 6.1 * use[i][v2] + 2 * use[i][o1] + 4.2 * use[i][o2] + 5 * use[i][o3]); model.add(8.8 * use[i][v1] + 6.1 * use[i][v2] + 2 * use[i][o1] + 4.2 * use[i][o2] + 5 * use[i][o3] <= 6 * produce[i]); model.add(produce[i] == IloSum(use[i])); // Raw oil can be stored for later use if (i == 0) { for (IloInt p = 0; p < nbProducts; p++) model.add(500 + buy[i][p] == use[i][p] + store[i][p]); } else { for (IloInt p = 0; p < nbProducts; p++) model.add(store[i-1][p] + buy[i][p] == use[i][p] + store[i][p]); } // Logical constraints // The food cannot use more than 3 oils // (or at least two oils must not be used) model.add((use[i][v1] == 0) + (use[i][v2] == 0) + (use[i][o1] == 0) + (use[i][o2] == 0) + (use[i][o3] == 0) >= 2); // When an oil is used, the quantity must be at least 20 tons for (p = 0; p < nbProducts; p++) model.add((use[i][p] == 0) || (use[i][p] >= 20)); // If products v1 or v2 are used, then product o3 is also used model.add(IloIfThen(env, (use[i][v1] >= 20) || (use[i][v2] >= 20), use[i][o3] >= 20)); // Objective function profit += 150 * produce[i] - IloScalProd(cost[i], buy[i]) - 5 * IloSum(store[i]); } // Objective function model.add(IloMaximize(env, profit)); IloCplex cplex(model); if (cplex.solve()) { cout << "Solution status: " << cplex.getStatus() << endl; cout << " Maximum profit = " << cplex.getObjValue() << endl; for (IloInt i = 0; i < nbMonths; i++) { IloInt p; cout << " Month " << i << " " << endl; cout << " . buy "; for (p = 0; p < nbProducts; p++) { cout << cplex.getValue(buy[i][p]) << "/t "; } cout << endl; cout << " . use "; for (p = 0; p < nbProducts; p++) { cout << cplex.getValue(use[i][p]) << "/t "; } cout << endl;//.........这里部分代码省略.........
开发者ID:annaPolytech,项目名称:PRD,代码行数:101,
示例3: mainint main(int argc, char* argv[]) { int returnCode = 0; std::string context; bool alwaysAddContext = true; //Default to only use 1 thread. We define this early since plugin system or message logger // may be using TBB. bool setNThreadsOnCommandLine = false; std::unique_ptr<tbb::task_scheduler_init> tsiPtr{new tbb::task_scheduler_init{1}}; boost::shared_ptr<edm::Presence> theMessageServicePresence; std::unique_ptr<std::ofstream> jobReportStreamPtr; boost::shared_ptr<edm::serviceregistry::ServiceWrapper<edm::JobReport> > jobRep; EventProcessorWithSentry proc; try { try { // NOTE: MacOs X has a lower rlimit for opened file descriptor than Linux (256 // in Snow Leopard vs 512 in SLC5). This is a problem for some of the workflows // that open many small root datafiles. Notice that this is safe to do also // for Linux, but we agreed not to change the behavior there for the moment. // Also the limits imposed by ulimit are not affected and still apply, if // there.#ifdef __APPLE__ context = "Setting file descriptor limit"; struct rlimit limits; getrlimit(RLIMIT_NOFILE, &limits); limits.rlim_cur = (OPEN_MAX < limits.rlim_max) ? OPEN_MAX : limits.rlim_max; setrlimit(RLIMIT_NOFILE, &limits);#endif context = "Initializing plug-in manager"; edmplugin::PluginManager::configure(edmplugin::standard::config()); // Decide whether to use the multi-thread or single-thread message logger // (Just walk the command-line arguments, since the boost parser will // be run below and can lead to error messages which should be sent via // the message logger) context = "Initializing either multi-threaded or single-threaded message logger"; bool multiThreadML = false; for(int i = 0; i < argc; ++i) { if((std::strncmp (argv[i], "-t", 20) == 0) || (std::strncmp (argv[i], "--multithreadML", 20) == 0)) { multiThreadML = true; break; } } // Load the message service plug-in if(multiThreadML) { theMessageServicePresence = boost::shared_ptr<edm::Presence>(edm::PresenceFactory::get()-> makePresence("MessageServicePresence").release()); } else { theMessageServicePresence = boost::shared_ptr<edm::Presence>(edm::PresenceFactory::get()-> makePresence("SingleThreadMSPresence").release()); } context = "Processing command line arguments"; std::string descString(argv[0]); descString += " [options] [--"; descString += kParameterSetOpt; descString += "] config_file /nAllowed options"; boost::program_options::options_description desc(descString); desc.add_options() (kHelpCommandOpt, "produce help message") (kParameterSetCommandOpt, boost::program_options::value<std::string>(), "configuration file") (kJobreportCommandOpt, boost::program_options::value<std::string>(), "file name to use for a job report file: default extension is .xml") (kEnableJobreportCommandOpt, "enable job report files (if any) specified in configuration file") (kJobModeCommandOpt, boost::program_options::value<std::string>(), "Job Mode for MessageLogger defaults - default mode is grid") (kNumberOfThreadsCommandOpt,boost::program_options::value<unsigned int>(), "Number of threads to use in job (0 is use all CPUs)") (kMultiThreadMessageLoggerOpt, "MessageLogger handles multiple threads - default is single-thread") (kStrictOpt, "strict parsing"); // anything at the end will be ignored, and sent to python boost::program_options::positional_options_description p; p.add(kParameterSetOpt, 1).add(kPythonOpt, -1); // This --fwk option is not used anymore, but I'm leaving it around as // it might be useful again in the future for code development // purposes. We originally used it when implementing the boost // state machine code. boost::program_options::options_description hidden("hidden options"); hidden.add_options()("fwk", "For use only by Framework Developers") (kPythonOpt, boost::program_options::value< std::vector<std::string> >(), "options at the end to be passed to python"); boost::program_options::options_description all_options("All Options"); all_options.add(desc).add(hidden); boost::program_options::variables_map vm; try { store(boost::program_options::command_line_parser(argc, argv).options(all_options).positional(p).run(), vm);//.........这里部分代码省略.........
开发者ID:aashaqshah,项目名称:cmssw-1,代码行数:101,
示例4: store void store( const trx_block& b, const signed_transactions& deterministic_trxs, const block_evaluation_state_ptr& state ){ try { std::vector<uint160> trxs_ids; uint16_t t = 0; std::map<int32_t,uint64_t> delegate_votes; for( uint32_t i = 1; i <= 100; ++i ) { delegate_votes[i] = 0; } for( ; t < b.trxs.size(); ++t ) { store( b.trxs[t], trx_num( b.block_num, t) ); trxs_ids.push_back( b.trxs[t].id() ); /*** on the genesis block we need to store initial delegates and vote counts */ if( b.block_num == 0 ) { if( t == 0 ) { for( uint32_t o = 0; o < b.trxs[t].outputs.size(); ++o ) { if( b.trxs[t].outputs[o].claim_func == claim_name ) { auto claim = b.trxs[t].outputs[o].as<claim_name_output>(); update_name_record( claim.name, claim ); // if( claim.delegate_id != 0 ) update_delegate( name_record( claim ) ); } } } else // t != 0 { name_record rec = _delegate_records.fetch( b.trxs[t].vote ); // first transaction registers names... the rest are initial balance for( uint32_t o = 0; o < b.trxs[t].outputs.size(); ++o ) { delegate_votes[b.trxs[t].vote] += b.trxs[t].outputs[o].amount.get_rounded_amount(); rec.votes_for += to_bips( b.trxs[t].outputs[o].amount.get_rounded_amount(), b.total_shares ); } update_delegate( rec ); } } // block == 0 } elog( "total votes:/n ${e}", ("e",fc::json::to_pretty_string( delegate_votes) ) ); uint64_t sum = 0; for( auto i : delegate_votes ) { sum += i.second; } elog( "grand total: ${g}", ("g",sum) ); for( const signed_transaction& trx : deterministic_trxs ) { store( trx, trx_num( b.block_num, t) ); ++t; // trxs_ids.push_back( trx.id() ); } head_block = b; head_block_id = b.id(); blocks.store( b.block_num, b ); block_trxs.store( b.block_num, trxs_ids ); blk_id2num.store( b.id(), b.block_num ); for( auto item : state->_name_outputs ) { update_name_record( item.first, item.second ); } for( auto item : state->_input_votes ) { auto rec = _delegate_records.fetch( abs(item.first) ); if( item.first < 0 ) rec.votes_against -= to_bips(item.second,b.total_shares); else rec.votes_for -= to_bips(item.second,b.total_shares); update_delegate( rec ); } for( auto item : state->_output_votes ) { auto rec = _delegate_records.fetch( abs(item.first) ); if( item.first < 0 ) rec.votes_against += to_bips( item.second, b.total_shares ); else rec.votes_for += to_bips( item.second, b.total_shares ); update_delegate( rec ); } } FC_RETHROW_EXCEPTIONS( warn, "" ) }
开发者ID:Coinfo,项目名称:bitshares_toolkit,代码行数:92,
示例5: mainint main(){ personagem per; monstro mon; char *map; char tEnd=1,tQuit=1,tRoom, test,test2; item it; strcpy(it.nome,"Capa Vampirica/0"); it.categoria='a'; it.value=80; monstro blair; blair.magicD = 160; blair.fisicalD = 160; blair.distD = 160; blair.atkType = 'm'; blair.atk = 250; strcpy(blair.nome,"Bruxa Blair/0"); strcpy(blair.drop,"Camiseta do TUSCA/0"); blair.HP = 120; blair.XP = 0; srand(time(NULL)); do{ test=start(&per,&map); if(test==2)continue; if(test==1)break; scanf("%*c"); do{ system("cls"); printf("SALA %i/n",per.pos); printf("deseja mexer em seu inventario?(s/n):"); scanf("%c",&test); if(test=='s'){ invMenu(&per);///cuidado olhar argumentos } do{ printf("Digite a direcao que dejeja seguir:norte-w; sul-s; leste-d; oeste-a; quit game-q:"); scanf("%c",&test); }while(test!='w' && test!='a' && test!='s' && test!='d' && test!='q'); if(test=='q'){ printf("deseja salvar o seu progresso?(s/n)"); scanf("%*c"); scanf("%*c"); scanf("%c",&test); if(test=='s'){ test2=save(per); } tQuit=0; break; } else{ move(test,&(per.pos)); } printf("SALA %i/n",per.pos); switch(map[per.pos]){ case 0://sala qualquer sem importancia tRoom=rand()%100; if(tRoom>=35){ mon=monsterGet(rand()%monsterNum); tQuit=combat(&per,&mon); break; } if(tRoom>=15){ printf("nao ha nada na sala/n"); break; } if(tRoom>=5){ printf("voce encontrou uma fonte de cura, e aproveitou para relaxar e tomar um banho, afinal ate os herois ficam cansados(as)."); printf(" Alem de especialmente fedidos(as) afinal de contas um covil de monstros nao cheiram tao bem assim (na maioria dos casos)/n"); heal(&per); break; } item it; test2=itemGet(rand()%itemNum,&it); printf("voce encontrou um '%s' deseja guardar no seu inventario?(s/n)/n",it.nome); scanf("%*c"); scanf("%c",&test); if(test=='s'){ store(it); } break; case 1://sala 0 printf("SALA ZERO/n/n"); printf("Voce esta em uma sala ampla com paredes e chao de pedra, ao seu redor existem varios destrocos pedacos de madeira e pedra, provavelmente vindos do telhado, "); printf("ja partido com frestas que permitem observar um o azul do ceu, e da decoracao, que antes imponente e bela agora nao passa de escombros/n/n"); printf("mas voce eh capaz de identificar no meio disso um pedestal de pedra e sobre ele apenas os pes do que um dia ja foi uma estatua e uma inscricao que diz:/n"); printf("'voce esta agora em um local seguro jovem aventureiro ou aventureira, aproveite este lugar para se preparar para as aventuras que estao a seguir.'"); printf("/n o resto estva ilegivel apagado pelo tempo. Voce aproveita a seguranca temporaria para se preparar para o que ha a seguir");//.........这里部分代码省略.........
开发者ID:malalves,项目名称:trabalho-final-LPA,代码行数:101,
示例6: current//.........这里部分代码省略......... *p++ = ' '; s++; } else if (*s == '/r' || *s == '/n') { s++; } else { *p++ = *s++; } /* skip duplicated space */ if (p > text + 2) if (*(p - 1) == ' ' && *(p - 2) == ' ') { p--; } continue; case 4: /* get current->end or skip <TAG> */ q = (wchar_t*)stristr(s, L"Start="); if (q) { int sec1000 = strtol(q + 6, &q, 0); current.stop = this->hmsToTime(0, 0, sec1000 / 1000, (sec1000 % 1000) / 10 - 1); *p = '/0'; trail_space(text); if (text[0] != '/0') { current.add(text); } if (current.size() > 0) { state = 99; break; } state = 0; continue; } s = strchr(s, '>'); if (s) { s++; state = 3; continue; } break; case 5: /* get rid of {...} text, but read the alignment code */ if ((*s == '//') && (*(s + 1) == 'a') && !sub_no_text_pp) { if (stristr(s, L"//a1") != NULL) { //current->alignment = SUB_ALIGNMENT_BOTTOMLEFT; s = s + 3; } if (stristr(s, L"//a2") != NULL) { //current->alignment = SUB_ALIGNMENT_BOTTOMCENTER; s = s + 3; } else if (stristr(s, L"//a3") != NULL) { //current->alignment = SUB_ALIGNMENT_BOTTOMRIGHT; s = s + 3; } else if ((stristr(s, L"//a4") != NULL) || (stristr(s, L"//a5") != NULL) || (stristr(s, L"//a8") != NULL)) { //current->alignment = SUB_ALIGNMENT_TOPLEFT; s = s + 3; } else if (stristr(s, L"//a6") != NULL) { //current->alignment = SUB_ALIGNMENT_TOPCENTER; s = s + 3; } else if (stristr(s, L"//a7") != NULL) { //current->alignment = SUB_ALIGNMENT_TOPRIGHT; s = s + 3; } else if (stristr(s, L"//a9") != NULL) { //current->alignment = SUB_ALIGNMENT_MIDDLELEFT; s = s + 3; } else if (stristr(s, L"//a10") != NULL) { //current->alignment = SUB_ALIGNMENT_MIDDLECENTER; s = s + 4; } else if (stristr(s, L"//a11") != NULL) { //current->alignment = SUB_ALIGNMENT_MIDDLERIGHT; s = s + 4; } } if (*s == '}') { state = 3; } ++s; continue; } /* read next line */ if (state != 99 && (s = fd.fgets(line, this->LINE_LEN)) == NULL) { if (current.start > 0) { break; // if it is the last subtitle } else { return NULL; } } } while (state != 99); // For the last subtitle if (current.stop <= 0) { current.stop = current.start + this->hmsToTime(0, 0, sub_slacktime / 1000, (sub_slacktime % 1000) / 10); *p = '/0'; trail_space(text); if (text[0] != '/0') { current.add(text); } } return store(current);}
开发者ID:xinjiguaike,项目名称:ffdshow,代码行数:101,
示例7: checkInstruction//.........这里部分代码省略......... append(ip); } if(ry!=NULL){ // set properties for register ry->dist=distance(p, ry->value); ry->dirty=true; } } } else ry=NULL;// 2nd step: allocate the 'rt' temporary register; creates the 'ti' temporary instruction// -- ti = createInstruction(idx++); // get 'rx' if(isNumeric(p->src1)) copy(ti->src1, p->src1); // found a constant else if(rx!=NULL) copy(ti->src1, rx->name); // got the 'rx' // get the operator ti->ops2=p->ops2; // get 'ry' if(isNumeric(p->src2)) copy(ti->src2, p->src2); // found a constant else if(ry!=NULL) copy(ti->src2, ry->name); // got the 'ry' if((p->dst[0] != '/0') && !isNumeric(p->dst)){ // allocate the 'rt' register ("r0" by default) rt=reg_search("store");// rt=reg_get(); if(rt!=NULL) rt->dirty=false; } else rt=NULL; // this could lead to an error if(rt!=NULL) copy(ti->dst, rt->name); append(ti);// 3rd step: frees if possible frees 'rx' and 'ry'// -- // free 'rx' if((rx!=NULL) && (rx->dist==MAXDIST || rx->dist==-2)) reg_free(rx); // free 'ry' if((ry!=NULL) && (ry->dist==MAXDIST || ry->dist==-2)) reg_free(ry);// 4th step: allocate the 'rz' register and create the main instruction 'mi'// -- mi = createInstruction(idx++); // allocate the 'rz' register if((p->dst[0] != '/0') && !isNumeric(p->dst)){ // store store(p->dst); rz=reg_search(p->dst); if(rz==NULL){
开发者ID:Andre-Pires,项目名称:Compilers,代码行数:66,
示例8: mainint main(int argc, char** argv) { google::InitGoogleLogging(argv[0]); // Declare a group of options that will be allowed // only on the command line po::options_description generic("Generic options"); generic.add_options() ("data", po::value<std::string>(), "Path to split data") ("rank,k", po::value<int>()->default_value(7), "Rank of the factors") ; // Declare a group of options that will be allowed // both on the command line and in a config file po::options_description config("Configuration"); config.add_options() ("clients", po::value<int>()->default_value(1), "Number of clients") ("id", po::value<int>()->default_value(0), "This client's ID") ("workers", po::value<int>()->default_value(3), "Number of worker threads per client") ("iterations,i", po::value<int>()->default_value(1), "Number of iterations") ("users", po::value<int>(), "Number of users") ("products", po::value<int>(), "Number of products") ("words", po::value<int>()->default_value(2938), "Number of words") ("seed", po::value<int>()->default_value(0), "Random seed") ("atol", po::value<float>()->default_value(0.01), "Minimum absolute MSE improvement before termination") ("rtol", po::value<float>()->default_value(0.01), "Minimum relative MSE improvement before termination") ("clamp", po::value<bool>()->default_value(false), "If true, then use non-negative projection.") ("reg", po::value<bool>()->default_value(false), "If true, then regularize.") ("reg-thr", po::value<int>()->default_value(1), "Iteration in which to start regularize") ("lambda", po::value<float>()->default_value(0.5), "Weight of the l2 regularizer") ("stop-tol,s", po::value<int>()->default_value(3), "Stop if no improvement were made in last s iterations") ; po::options_description cmdline_options; cmdline_options.add(generic).add(config); po::options_description config_file_options; config_file_options.add(config); po::variables_map vm; store(po::command_line_parser(argc, argv).options(cmdline_options).run(), vm); std::string datapath = vm["data"].as<std::string>(); int rank = vm["rank"].as<int>(); std::ifstream ifs(datapath + "/run_config.cfg"); store(parse_config_file(ifs, config_file_options), vm); //notify(vm); int client_id = vm["id"].as<int>(); int num_clients = vm["clients"].as<int>(); int num_workers = vm["workers"].as<int>(); int iterations = vm["iterations"].as<int>(); int num_users = vm["users"].as<int>(); int num_products = vm["products"].as<int>(); int num_words = vm["words"].as<int>(); int seed = vm["seed"].as<int>(); float atol = vm["atol"].as<float>(); float rtol = vm["rtol"].as<float>(); bool clamp = vm["clamp"].as<bool>(); bool reg = vm["reg"].as<bool>(); int reg_thr = vm["reg-thr"].as<int>(); float lambda = vm["lambda"].as<float>(); int stop_tol = vm["stop-tol"].as<int>(); // Register row types petuum::PSTableGroup::RegisterRow<petuum::DenseRow<float>>(RowType::FLOAT); // Initialize group petuum::TableGroupConfig table_group_config; table_group_config.host_map.insert( std::make_pair(0, petuum::HostInfo(0, "127.0.0.1", "10000"))); table_group_config.consistency_model = petuum::SSP; table_group_config.num_tables = 4; table_group_config.num_total_clients = num_clients; table_group_config.num_local_app_threads = num_workers + 1; // Somehow a larger number than 1 leads to hanging at the end while the main // thread waits for all seRproder threads to terminate. Apparently one of them is // not receiving a kClientShutDown message. table_group_config.num_comm_channels_per_client = 1; table_group_config.client_id = client_id; petuum::PSTableGroup::Init(table_group_config, false); // create tables gaml::tf::Worker::initTables(Table::U, Table::P, Table::T, Table::SE, RowType::FLOAT, rank, num_users, num_products, num_words, iterations, num_workers); petuum::PSTableGroup::CreateTableDone(); std::vector<std::thread> threads(num_workers); // run workers for (int i = 0; i < num_workers; i++) {//.........这里部分代码省略.........
开发者ID:cqql,项目名称:tum-graph-analytics,代码行数:101,
示例9: storevoid SessionManagerTests::testSessionInfo(){ // Create an empty object store#ifndef _WIN32 ObjectStore store("./testdir");#else ObjectStore store(".//testdir");#endif // Create the managers SlotManager slotManager(&store); SessionManager sessionManager; // Get a slot CK_SLOT_ID slotID = 0; Slot* slot = slotManager.getSlot(slotID); // Initialize the token ByteString soPIN((unsigned char*)"1234", 4); ByteString userPIN((unsigned char*)"1234", 4); CK_UTF8CHAR label[33] = "My test token "; CPPUNIT_ASSERT(slot->initToken(soPIN, label) == CKR_OK); CPPUNIT_ASSERT(slot->getToken()->loginSO(soPIN) == CKR_OK); CPPUNIT_ASSERT(slot->getToken()->initUserPIN(userPIN) == CKR_OK); slot->getToken()->logout(); // Get a session CK_SESSION_HANDLE hSession; CK_RV rv = sessionManager.openSession(slot, CKF_SERIAL_SESSION, NULL_PTR, NULL_PTR, &hSession); CPPUNIT_ASSERT(rv == CKR_OK); // Get session info CK_SESSION_INFO info; rv = sessionManager.getSessionInfo(CK_INVALID_HANDLE, &info); CPPUNIT_ASSERT(rv == CKR_SESSION_HANDLE_INVALID); rv = sessionManager.getSessionInfo(hSession, NULL_PTR); CPPUNIT_ASSERT(rv == CKR_ARGUMENTS_BAD); rv = sessionManager.getSessionInfo(hSession, &info); CPPUNIT_ASSERT(rv == CKR_OK); // Public RO session info CPPUNIT_ASSERT(info.slotID == slotID); CPPUNIT_ASSERT(info.state == CKS_RO_PUBLIC_SESSION); CPPUNIT_ASSERT(info.flags == CKF_SERIAL_SESSION); rv = sessionManager.closeSession(hSession); CPPUNIT_ASSERT(rv == CKR_OK); // Public RW session info rv = sessionManager.openSession(slot, CKF_SERIAL_SESSION | CKF_RW_SESSION, NULL_PTR, NULL_PTR, &hSession); CPPUNIT_ASSERT(rv == CKR_OK); Session* session = sessionManager.getSession(CK_INVALID_HANDLE); CPPUNIT_ASSERT(session == NULL); session = sessionManager.getSession(hSession); CPPUNIT_ASSERT(session != NULL); rv = session->getInfo(&info); CPPUNIT_ASSERT(rv == CKR_OK); CPPUNIT_ASSERT(info.state == CKS_RW_PUBLIC_SESSION); CPPUNIT_ASSERT(info.flags == (CKF_SERIAL_SESSION | CKF_RW_SESSION)); rv = sessionManager.closeSession(hSession); CPPUNIT_ASSERT(rv == CKR_OK); // User RO session info rv = slot->getToken()->loginUser(userPIN); CPPUNIT_ASSERT(rv == CKR_OK); rv = sessionManager.openSession(slot, CKF_SERIAL_SESSION, NULL_PTR, NULL_PTR, &hSession); CPPUNIT_ASSERT(rv == CKR_OK); rv = sessionManager.getSessionInfo(hSession, &info); CPPUNIT_ASSERT(rv == CKR_OK); CPPUNIT_ASSERT(info.state == CKS_RO_USER_FUNCTIONS); CPPUNIT_ASSERT(info.flags == CKF_SERIAL_SESSION); rv = sessionManager.closeSession(hSession); CPPUNIT_ASSERT(rv == CKR_OK); // User RW session info rv = slot->getToken()->loginUser(userPIN); CPPUNIT_ASSERT(rv == CKR_OK); rv = sessionManager.openSession(slot, CKF_SERIAL_SESSION | CKF_RW_SESSION, NULL_PTR, NULL_PTR, &hSession); CPPUNIT_ASSERT(rv == CKR_OK); rv = sessionManager.getSessionInfo(hSession, &info); CPPUNIT_ASSERT(rv == CKR_OK); CPPUNIT_ASSERT(info.state == CKS_RW_USER_FUNCTIONS); CPPUNIT_ASSERT(info.flags == (CKF_SERIAL_SESSION | CKF_RW_SESSION)); rv = sessionManager.closeSession(hSession); CPPUNIT_ASSERT(rv == CKR_OK); // SO RW session info rv = slot->getToken()->loginSO(soPIN); CPPUNIT_ASSERT(rv == CKR_OK); rv = sessionManager.openSession(slot, CKF_SERIAL_SESSION | CKF_RW_SESSION, NULL_PTR, NULL_PTR, &hSession); CPPUNIT_ASSERT(rv == CKR_OK); rv = sessionManager.getSessionInfo(hSession, &info); CPPUNIT_ASSERT(rv == CKR_OK); CPPUNIT_ASSERT(info.state == CKS_RW_SO_FUNCTIONS); CPPUNIT_ASSERT(info.flags == (CKF_SERIAL_SESSION | CKF_RW_SESSION)); rv = sessionManager.closeSession(hSession);//.........这里部分代码省略.........
开发者ID:bellgrim,项目名称:SoftHSMv2,代码行数:101,
示例10: storebool ECP::DecodePoint(ECP::Point &P, const byte *encodedPoint, size_t encodedPointLen) const{ StringStore store(encodedPoint, encodedPointLen); return DecodePoint(P, store, encodedPointLen);}
开发者ID:007pig,项目名称:BitcoinArmory,代码行数:5,
示例11: cleanup void cleanup() { Akonadi2::Storage store(Akonadi2::Store::storageLocation(), "org.kde.dummy.testindex", Akonadi2::Storage::ReadWrite); store.removeFromDisk(); }
开发者ID:KDE,项目名称:sink,代码行数:5,
示例12: simulateToRead void simulateToRead() { if (_debug) printf("%*s% 7.2lf ", _indent*8, "", _tNextStop/(400.0*256.0)); int pc = _pch | _memory[2]; int op = _program->op(pc); incrementPC(); UInt16 r; if ((op & 0x800) == 0) { _f = op & 0x1f; if ((op & 0x400) == 0) { bool d = ((op & 0x20) != 0); // true if destination is f, false if destination is W char dc = d ? 'f' : 'W'; switch (op >> 6) { case 0x0: if (!d) switch (_f) { case 0: if (_debug) { printf("NOP "); printf("/n"); } _f = -1; break; case 2: if (_debug) { printf("OPTION "); printf("/n"); } _f = -1; _option = _w; break; case 3: if (_debug) { printf("SLEEP "); printf("/n"); } _f = -1; throw Exception(String("SLEEP not supported")); break; case 4: if (_debug) { printf("CLRWDT "); printf("/n"); } _f = -1; throw Exception(String("CLRWDT not supported")); break; case 6: if (_debug) { printf("TRIS GPIO "); printf("/n"); } _f = 0x20; _data = _w; break; default: unrecognizedOpcode(op); break; } else { if (_debug) { printf("MOVWF 0x%02x ", _f); printf("/n"); } _data = _w; } break; case 0x1: if (_debug) { if (!d) printf("CLRW "); else printf("CLRF 0x%02x ", _f); printf("/n"); } storeZ(0, d); break; case 0x2: if (_debug) { printf("SUBWF 0x%02x, %c ", _f, dc); printf("/n"); } { UInt8 m = readMemory(_f); r = m - _w; if (r & 0x100) _memory[3] |= 1; else _memory[3] &= 0xfe; if ((m & 0xf) - (_w & 0xf) != (r & 0xf)) _memory[3] |= 2; else _memory[3] &= 0xfd; storeZ(r, d); } break; case 0x3: if (_debug) { printf("DECF 0x%02x, %c ", _f, dc); printf("/n"); } storeZ(readMemory(_f) - 1, d); break; case 0x4: if (_debug) { printf("IORWF 0x%02x, %c ", _f, dc); printf("/n"); } storeZ(readMemory(_f) | _w, d); break; case 0x5: if (_debug) { printf("ANDWF 0x%02x, %c ", _f, dc); printf("/n"); } storeZ(readMemory(_f) & _w, d); break; case 0x6: if (_debug) { printf("XORWF 0x%02x, %c ", _f, dc); printf("/n"); } storeZ(readMemory(_f) ^ _w, d); break; case 0x7: if (_debug) { printf("ADDWF 0x%02x, %c ", _f, dc); printf("/n"); } { UInt8 m = readMemory(_f); r = m + _w; if (r & 0x100) _memory[3] |= 1; else//.........这里部分代码省略.........
开发者ID:reenigne,项目名称:reenigne,代码行数:101,
示例13: storeCalibrate::~Calibrate(){ store();}
开发者ID:muromec,项目名称:qtopia-ezx,代码行数:4,
示例14: storevoid CConfigAISH::store(CConfigManager &ConfMan)const{ store(ConfMan.GetSection(_T("AISH")));}
开发者ID:Claybird,项目名称:lhaforge,代码行数:4,
示例15: while//.........这里部分代码省略......... } if (event.text) {#if 0 DPRINTF(L"%s", event.text.c_str());#endif int hour1 = 0, min1 = 0, sec1 = 0, hunsec1 = 0; int hour2 = 0, min2 = 0, sec2 = 0, hunsec2 = 0; if (!(flags & this->PARSETIME) || (swscanf(event.start.c_str(), L"%d:%d:%d.%d", &hour1, &min1, &sec1, &hunsec1) == 4 && swscanf(event.end.c_str() , L"%d:%d:%d.%d", &hour2, &min2, &sec2, &hunsec2) == 4)) { const TSubtitleProps *props = styles.getProps(event.style); TsubtitleText current(this->format, props ? *props : defprops, styles); current.defProps.lineID = lineID; // margins nmTextSubtitles::strToIntMargin(event.marginL, ¤t.defProps.marginL); nmTextSubtitles::strToIntMargin(event.marginR, ¤t.defProps.marginR); nmTextSubtitles::strToIntMargin(event.marginV, ¤t.defProps.marginV); // layer nmTextSubtitles::strToInt(event.layer, ¤t.defProps.layer); // timestamps if (flags & this->PARSETIME) { current.start = timer.den * this->hmsToTime(hour1, min1, sec1, hunsec1) / timer.num; current.stop = timer.den * this->hmsToTime(hour2, min2, sec2, hunsec2) / timer.num; } else if (start != REFTIME_INVALID && stop != REFTIME_INVALID) { current.start = start; current.stop = stop; } current.defProps.tStart = current.defProps.karaokeStart = current.start; current.defProps.tStop = current.stop; // scroll event.effect = event.effect.ConvertToLowerCase(); if (event.effect.find(L"scroll up;") != ffstring::npos) { current.defProps.scroll.directionV = -1; } if (event.effect.find(L"scroll down;") != ffstring::npos) { current.defProps.scroll.directionV = 1; } if (current.defProps.scroll.directionV) { int y1, y2, delay, fadeawayheight = 0; if (swscanf(event.effect.c_str() + event.effect.find(L";"), L";%d;%d;%d;%d", &y1, &y2, &delay, &fadeawayheight) >= 3) { if (y1 > y2) { std::swap(y1, y2); } current.defProps.scroll.y1 = y1; current.defProps.scroll.y2 = y2; current.defProps.scroll.delay = std::max(delay, 1); current.defProps.scroll.fadeaway = fadeawayheight; } } if (event.effect.find(L"banner;") != ffstring::npos) { current.defProps.scroll.directionV = 0; current.defProps.scroll.directionH = -1; int delay, lefttoright = 0, fadeawaywidth = 0; if (swscanf(event.effect.c_str() + event.effect.find(L";"), L";%d;%d;%d", &delay, &lefttoright, &fadeawaywidth) >= 1) { current.defProps.scroll.delay = std::max(delay, 1); current.defProps.scroll.directionH = lefttoright ? 1 : -1; current.defProps.scroll.fadeaway = fadeawaywidth; } } // replace /h with non-breaking space (U+00A0). event.text = stringreplace(event.text, L"//h", L"/xa0", rfReplaceAll); const wchar_t *line2 = event.text.c_str(); do { const wchar_t *tmp, *tmp1; int lineBreakReason = 0; do { tmp = strstr(line2, L"//n"); tmp1 = strstr(line2, L"//N"); if (tmp == NULL && tmp1 == NULL) { break; } if (tmp && tmp1) { tmp = std::min(tmp, tmp1); } if (tmp == NULL) { tmp = tmp1; } current.addSSA(line2, tmp - line2, lineBreakReason); lineBreakReason = tmp[1] == 'n' ? 1 : 2; line2 = tmp + 2; } while (1); current.addSSA(line2, lineBreakReason); } while (flags & this->SSA_NODIALOGUE && fd.fgets((wchar_t*)(line2 = line), this->LINE_LEN)); textformat.setProps(current.defProps); return store(current); } } } } return NULL;}
开发者ID:xinjiguaike,项目名称:ffdshow,代码行数:101,
示例16: display void display() { std::vector<cv::Point2f> pointsColor, pointsIr; cv::Mat color, ir, irGrey, depth; cv::Mat colorDisp, irDisp; bool foundColor = false; bool foundIr = false; bool save = false; bool running = true; std::chrono::milliseconds duration(1); while(!update && ros::ok()) { std::this_thread::sleep_for(duration); } for(; ros::ok() && running;) { if(update) { lock.lock(); color = this->color; ir = this->ir; irGrey = this->irGrey; depth = this->depth; foundColor = this->foundColor; foundIr = this->foundIr; pointsColor = this->pointsColor; pointsIr = this->pointsIr; update = false; lock.unlock(); if(mode == COLOR || mode == SYNC) { cv::cvtColor(color, colorDisp, CV_GRAY2BGR); cv::drawChessboardCorners(colorDisp, boardDims, pointsColor, foundColor); //cv::resize(colorDisp, colorDisp, cv::Size(), 0.5, 0.5); //cv::flip(colorDisp, colorDisp, 1); } if(mode == IR || mode == SYNC) { cv::cvtColor(irGrey, irDisp, CV_GRAY2BGR); cv::drawChessboardCorners(irDisp, boardDims, pointsIr, foundIr); //cv::resize(irDisp, irDisp, cv::Size(), 0.5, 0.5); //cv::flip(irDisp, irDisp, 1); } } switch(mode) { case COLOR: cv::imshow("color", colorDisp); break; case IR: cv::imshow("ir", irDisp); break; case SYNC: cv::imshow("color", colorDisp); cv::imshow("ir", irDisp); break; } int key = cv::waitKey(10); switch(key & 0xFF) { case ' ': case 's': save = true; break; case 27: case 'q': running = false; break; case '1': minIr = std::max(0, minIr - 100); break; case '2': minIr = std::min(maxIr - 1, minIr + 100); break; case '3': maxIr = std::max(minIr + 1, maxIr - 100); break; case '4': maxIr = std::min(0xFFFF, maxIr + 100); break; case 'l': minIr = std::max(0, minIr - 100); maxIr = std::max(minIr + 1, maxIr - 100); break; case 'h': maxIr = std::min(0x7FFF, maxIr + 100); minIr = std::min(maxIr - 1, minIr + 100); break; } if(save && ((mode == COLOR && foundColor) || (mode == IR && foundIr) || (mode == SYNC && foundColor && foundIr))) { store(color, ir, irGrey, depth, pointsColor, pointsIr); save = false; }//.........这里部分代码省略.........
开发者ID:mitchellwills,项目名称:iai_kinect2,代码行数:101,
示例17: newSize//! Grows the hash table.voiddmz::HashTableUInt32::grow (const Int32 Size) { Int32 newSize (0); if (_state.autoGrow) { if (!Size) { if (!_state.size) { newSize = 1; } else { newSize = _state.size; newSize = newSize << 1; } } else { if (Size > _state.size) { newSize = _state.size; if (!newSize) { newSize = 1; } while ((newSize < Size) && (newSize <= 0x80000000)) { newSize = newSize << 1; } } } } if (newSize) { _state.growCount++; const Int32 OldSize (_state.size); const Int32 OldCount (_state.count); DataStruct *table (_state.table); _state.size = 0; _state.count = 0; _state.table = new DataStruct[newSize]; if (table && _state.table) { _state.size = newSize; DataStruct *cur (_state.head); _state.tail = _state.head = 0; while (cur) { store (cur->key, cur->data); cur = cur->next; } delete []table; table = 0; } else if (_state.table) { _state.size = newSize; } else if (table) { _state.table = table; _state.size = OldSize; _state.count = OldCount; } }}
开发者ID:Andais,项目名称:dmz,代码行数:63,
示例18: storevoid scoped_weapon_info::activate(){ if (data_) { store(data_); }}
开发者ID:justinzane,项目名称:wesnoth-ng,代码行数:6,
示例19: analyse//词法分析主分析函数 Result analyse(long * readIndexPtr,char buf[],long length,FILE * outFile,int line){ printf("readindex: %ld/n",*readIndexPtr); int status = 0; char token[16] = ""; char ch; for (;(*readIndexPtr) < length;){ ch = buf[(*readIndexPtr)++]; //printf("current char: %ld/n",*readIndexPtr); if (ch == EOF) { store(token,25,outFile); return (Result){25,0}; } //空格 else if (ch == 32 && status == 0) { status = 0; } //字母 else if (isLetter(ch)) { if (status == 0 || status == 1) { linkChar(token,ch); status = 1; continue; } else if (status == 3) { status = 4; (*readIndexPtr) --; //常数 store(token,11,outFile); return (Result){11,0}; } } //数字 else if (isNumber(ch)) { if (status == 1) { linkChar(token,ch); status = 1; } else if (status == 0 ||status == 3) { linkChar(token,ch); status = 3; } } //非字母/数字 else { if (status == 1) { status = 2; (*readIndexPtr) --; //标示符/保留字的处理 return identifier(token,outFile); } else if (status == 3) { status = 4; (*readIndexPtr) --; //常数 store(token,11,outFile); return (Result){11,0}; } else switch (ch) { case '=': linkChar(token,ch); status = 5; store(token,12,outFile); return (Result){12,0}; break; case '-': linkChar(token,ch); status = 6; store(token,18,outFile); return (Result){18,0}; break; case '*': linkChar(token,ch); status = 7; store(token,19,outFile); return (Result){19,0}; break; case '(': linkChar(token,ch); status = 8; store(token,21,outFile); return (Result){21,0}; break; case ')': linkChar(token,ch); status = 9; store(token,22,outFile); return (Result){22,0}; break; case '<': linkChar(token,ch); status = 10; if ((*readIndexPtr) < length) { ch = buf[(*readIndexPtr)++]; switch (ch) { case '=': linkChar(token,ch);//.........这里部分代码省略.........
开发者ID:yubaoquan,项目名称:compiler,代码行数:101,
示例20: as_output_dataframeSEXP as_output_dataframe(SEXP sWhat, SEXP sSep, SEXP sNsep, SEXP sRownamesFlag, SEXP sConn, SEXP sRecycle) { unsigned long i, j; if (TYPEOF(sWhat) != VECSXP) Rf_error("object must be a data.frame"); unsigned long ncol = XLENGTH(sWhat); unsigned long nrow = 0; unsigned long row_len = 0; if (ncol) nrow = XLENGTH(VECTOR_ELT(sWhat, 0)); int rownamesFlag = asInteger(sRownamesFlag); if (TYPEOF(sSep) != STRSXP || LENGTH(sSep) != 1) Rf_error("sep must be a single string"); if (TYPEOF(sNsep) != STRSXP || LENGTH(sNsep) != 1) Rf_error("nsep must be a single string"); char sep = CHAR(STRING_ELT(sSep, 0))[0]; char nsep = CHAR(STRING_ELT(sNsep, 0))[0]; char lend = '/n'; SEXP sRnames = getAttrib0(sWhat, R_RowNamesSymbol); int isConn = inherits(sConn, "connection"), mod = 0; int recycle = (asInteger(sRecycle) > 0) ? 1 : 0; SEXP as_character = R_NilValue; unsigned long *sizes = 0; if (TYPEOF(sRnames) != STRSXP) sRnames = NULL; for (j = 0; j < ncol; j++) { /* we have to call as.character() for objects with a class since they may require a different representation */ if (requires_as_character(VECTOR_ELT(sWhat, j))) { /* did we create a modified copy yet? If not, do so */ if (!mod) { /* shallow copy - we use it only internally so should be ok */ SEXP sData = PROTECT(allocVector(VECSXP, XLENGTH(sWhat))); memcpy(&(VECTOR_ELT(sData, 0)), &(VECTOR_ELT(sWhat, 0)), sizeof(SEXP) * XLENGTH(sWhat)); sWhat = sData; mod = 1; as_character = Rf_install("as.character"); } SEXP asc = PROTECT(lang2(as_character, VECTOR_ELT(sWhat, j))); SET_VECTOR_ELT(sWhat, j, eval(asc, R_GlobalEnv)); UNPROTECT(1); } row_len += guess_size(TYPEOF(VECTOR_ELT(sWhat, j))); } if (ncol && recycle) { /* this allows us to support lists directly without requiring for them to be a data frames - in those cases we have to check the length of the columns to determine the longest */ unsigned long min_len = (unsigned long) XLENGTH(VECTOR_ELT(sWhat, 0)); for (j = 0; j < ncol; j++) { unsigned long l = 0; SEXP el = VECTOR_ELT(sWhat, j); /* NOTE: we can assume that el must be a scalar vector since anything that isn't will be passed through as.character() */ l = (unsigned long) XLENGTH(el); if (l < min_len) min_len = l; if (l > nrow) nrow = l; } /* if all elements have the smae tlength then we don't need to re-cycle, so treat the list exactly like a data frame */ if (nrow == min_len) recycle = 0; else { /* cache lengths since XLENGTH is actually not a cheap operation */ SEXP foo = PROTECT(allocVector(RAWSXP, sizeof(long) * ncol)); sizes = (unsigned long*) RAW(foo); for (j = 0; j < ncol; j++) sizes[j] = (unsigned long) XLENGTH(VECTOR_ELT(sWhat, j)); } } if (rownamesFlag == 1) row_len++; SEXP buf = dybuf_alloc(isConn ? DEFAULT_CONN_BUFFER_SIZE : (row_len * nrow), sConn); for (i = 0; i < nrow; i++) { if (rownamesFlag) { if (sRnames) { const char *c = CHAR(STRING_ELT(sRnames, i)); dybuf_add(buf, c, strlen(c)); } else { /* FIXME: use sprintf("%d", i) for automatic row names? */ } dybuf_add1(buf, nsep); } if (recycle) /* slower - we need to use modulo to recycle */ /* FIXME: modulo is slow for large vectors, should we just keep separate index for every column? It may be worth measuring the impact ... We are already trying to be smart by avoiding modulo for the two most common cases: full-length vectors and vectors of length 1 so this will only impact non-trivial recycling */ for (j = 0; j < ncol; j++) { store(buf, VECTOR_ELT(sWhat, j), (i < sizes[j]) ? i : ((sizes[j] == 1) ? 0 : (i % sizes[j]))); if (j < ncol - 1) dybuf_add1(buf, (rownamesFlag == 2 && j == 0) ? nsep : sep); } else for (j = 0; j < ncol; j++) { store(buf, VECTOR_ELT(sWhat, j), i); if (j < ncol - 1) dybuf_add1(buf, (rownamesFlag == 2 && j == 0) ? nsep : sep);//.........这里部分代码省略.........
开发者ID:s-u,项目名称:iotools,代码行数:101,
示例21: increment_and_get int64_t increment_and_get( uint64_t inc ) { auto tmp = aquire() + inc; store( tmp ); return tmp; }
开发者ID:bytemaster,项目名称:fc_malloc,代码行数:6,
示例22: LOG/* * This will consume+delete updates from the passed nsTArray.*/nsresultClassifier::ApplyTableUpdates(nsTArray<TableUpdate*>* aUpdates, const nsACString& aTable){ LOG(("Classifier::ApplyTableUpdates(%s)", PromiseFlatCString(aTable).get())); nsAutoPtr<HashStore> store(new HashStore(aTable, mStoreDirectory)); if (!store) return NS_ERROR_FAILURE; // take the quick exit if there is no valid update for us // (common case) uint32 validupdates = 0; for (uint32 i = 0; i < aUpdates->Length(); i++) { TableUpdate *update = aUpdates->ElementAt(i); if (!update || !update->TableName().Equals(store->TableName())) continue; if (update->Empty()) { aUpdates->ElementAt(i) = nullptr; delete update; continue; } validupdates++; } if (!validupdates) { return NS_OK; } nsresult rv = store->Open(); NS_ENSURE_SUCCESS(rv, rv); rv = store->BeginUpdate(); NS_ENSURE_SUCCESS(rv, rv); // Read the part of the store that is (only) in the cache LookupCache *prefixSet = GetLookupCache(store->TableName()); if (!prefixSet) { return NS_ERROR_FAILURE; } nsTArray<PRUint32> AddPrefixHashes; rv = prefixSet->GetPrefixes(&AddPrefixHashes); NS_ENSURE_SUCCESS(rv, rv); rv = store->AugmentAdds(AddPrefixHashes); NS_ENSURE_SUCCESS(rv, rv); AddPrefixHashes.Clear(); uint32 applied = 0; bool updateFreshness = false; for (uint32 i = 0; i < aUpdates->Length(); i++) { TableUpdate *update = aUpdates->ElementAt(i); if (!update || !update->TableName().Equals(store->TableName())) continue; rv = store->ApplyUpdate(*update); NS_ENSURE_SUCCESS(rv, rv); applied++; LOG(("Applied update to table %s:", store->TableName().get())); LOG((" %d add chunks", update->AddChunks().Length())); LOG((" %d add prefixes", update->AddPrefixes().Length())); LOG((" %d add completions", update->AddCompletes().Length())); LOG((" %d sub chunks", update->SubChunks().Length())); LOG((" %d sub prefixes", update->SubPrefixes().Length())); LOG((" %d sub completions", update->SubCompletes().Length())); LOG((" %d add expirations", update->AddExpirations().Length())); LOG((" %d sub expirations", update->SubExpirations().Length())); if (!update->IsLocalUpdate()) { updateFreshness = true; LOG(("Remote update, updating freshness")); } aUpdates->ElementAt(i) = nullptr; delete update; } LOG(("Applied %d update(s) to %s.", applied, store->TableName().get())); rv = store->Rebuild(); NS_ENSURE_SUCCESS(rv, rv); LOG(("Table %s now has:", store->TableName().get())); LOG((" %d add chunks", store->AddChunks().Length())); LOG((" %d add prefixes", store->AddPrefixes().Length())); LOG((" %d add completions", store->AddCompletes().Length())); LOG((" %d sub chunks", store->SubChunks().Length())); LOG((" %d sub prefixes", store->SubPrefixes().Length())); LOG((" %d sub completions", store->SubCompletes().Length())); rv = store->WriteFile(); NS_ENSURE_SUCCESS(rv, rv);//.........这里部分代码省略.........
开发者ID:FunkyVerb,项目名称:devtools-window,代码行数:101,
示例23: DependencyCountervoid SchedulerCPU::LaunchTasks(const FrameContextEx& context, std::function<jobs::Future<std::any>(const FrameContextEx&, const Pipeline&, lemon::ListDigraph::Node, std::any)> onNode) { struct DependencyCounter { public: explicit DependencyCounter(size_t total = 0) { this->total = total; } void Reset() { *counter = 0; } bool operator++() { return (counter->fetch_add(1) + 1) == total; } private: std::shared_ptr<std::atomic_size_t> counter = std::make_shared<std::atomic_size_t>(0); std::size_t total = 0; }; lemon::ListDigraph::NodeMap<DependencyCounter> depCounter(m_pipeline->GetTaskGraph()); for (lemon::ListDigraph::NodeIt nodeIt(m_pipeline->GetTaskGraph()); nodeIt != lemon::INVALID; ++nodeIt) { depCounter[nodeIt] = DependencyCounter{ (size_t)lemon::countInArcs(m_pipeline->GetTaskGraph(), nodeIt) }; } auto stopFlag = std::make_shared<std::atomic_bool>(false); auto Traverse = [this, &context, stopFlag, &onNode, &depCounter](lemon::ListDigraph::Node node, std::any passThrough, auto self) -> jobs::Future<void> { if (stopFlag->load()) { co_return; } try { std::any passToNext = co_await onNode(context, *m_pipeline, node, passThrough); std::vector<jobs::Future<void>> childJobs; for (lemon::ListDigraph::OutArcIt outArc(m_pipeline->GetTaskGraph(), node); outArc != lemon::INVALID; ++outArc) { auto nextNode = m_pipeline->GetTaskGraph().target(outArc); if (++depCounter[nextNode]) { childJobs.push_back(m_scheduler->Enqueue(self, nextNode, passToNext, self)); } } for (auto& childFuture : childJobs) { co_await childFuture; } } catch (...) { stopFlag->store(true); throw; } }; auto sourceNodes = GetSourceNodes(m_pipeline->GetTaskGraph()); std::vector<jobs::Future<void>> childJobs; for (auto sourceNode : sourceNodes) { childJobs.push_back(m_scheduler->Enqueue(Traverse, sourceNode, std::any{}, Traverse)); } std::vector<std::exception_ptr> exceptions; for (auto& job : childJobs) { try { job.get(); } catch (...) { exceptions.push_back(std::current_exception()); } } if (!exceptions.empty()) { // Rest of the exceptions is ignored. // TODO: throw some aggregate exception? std::rethrow_exception(exceptions[0]); }}
开发者ID:petiaccja,项目名称:Inline-Engine,代码行数:72,
示例24: mainintmain(int argc, char **argv){ krb5_context ctx; krb5_error_code retval; const char *progname; retval = krb5_init_context(&ctx); if (retval) { fprintf(stderr, "krb5_init_context returned error %ld/n", (long) retval); exit(1); } progname = argv[0]; /* Parse arguments. */ argc--; argv++; while (argc) { if (strcmp(*argv, "dump") == 0) { /* * Without going through the rcache interface, dump a * named dfl-format rcache file to stdout. Takes a full * pathname argument. */ const char *filename; argc--; argv++; if (!argc) usage(progname); filename = *argv; dump_rcache(filename); } else if (strcmp(*argv, "store") == 0) { /* * Using the rcache interface, store a replay record. * Takes an rcache spec like dfl:host as the first * argument. If non-empty, the "msg" argument will be * hashed and provided in the replay record. The * now-timestamp argument can be 0 to use the current * time. */ char *rcspec, *client, *server, *msg; krb5_timestamp timestamp, now_timestamp; krb5_int32 usec, now_usec; argc--; argv++; if (!argc) usage(progname); rcspec = *argv; argc--; argv++; if (!argc) usage(progname); client = *argv; argc--; argv++; if (!argc) usage(progname); server = *argv; argc--; argv++; if (!argc) usage(progname); msg = (**argv) ? *argv : NULL; argc--; argv++; if (!argc) usage(progname); timestamp = (krb5_timestamp) atoll(*argv); argc--; argv++; if (!argc) usage(progname); usec = (krb5_int32) atol(*argv); argc--; argv++; if (!argc) usage(progname); now_timestamp = (krb5_timestamp) atoll(*argv); argc--; argv++; if (!argc) usage(progname); now_usec = (krb5_int32) atol(*argv); store(ctx, rcspec, client, server, msg, timestamp, usec, now_timestamp, now_usec); } else if (strcmp(*argv, "expunge") == 0) { /* * Using the rcache interface, expunge a replay cache. * The now-timestamp argument can be 0 to use the current * time. */ char *rcspec; krb5_timestamp now_timestamp; krb5_int32 now_usec; argc--; argv++; if (!argc) usage(progname); rcspec = *argv; argc--; argv++; if (!argc) usage(progname); now_timestamp = (krb5_timestamp) atoll(*argv); argc--; argv++; if (!argc) usage(progname); now_usec = (krb5_int32) atol(*argv); expunge(ctx, rcspec, now_timestamp, now_usec); } else usage(progname); argc--; argv++; } krb5_free_context(ctx); return 0;}
开发者ID:INNOAUS,项目名称:krb5,代码行数:99,
示例25: storevoid Configuration::store(){ if (this->filename.size() > 0) { store(this->filename); }}
开发者ID:carpe-noctem-cassel,项目名称:supplementary,代码行数:6,
示例26: mainint main (int argc, char **argv)try { // Process the command line arguments std::string descString(argv[0]); descString += " option [options]/n/n"; descString += "Prints descriptions of the allowed/required parameters used to/n"; descString += "configure plugins. Output is ordered by plugin name. Within a/n"; descString += "plugin, the labels and parameters are ordered based on the order/n"; descString += "declared by the plugin. Formatted as follows:/n/n"; descString += "PluginName (PluginType) Library/n"; descString += " ModuleLabel/n"; descString += " Details of parameters corresponding to this module label/n/n"; descString += "For more information about the output format see:/n"; descString += "https://twiki.cern.ch/twiki/bin/view/CMS/SWGuideConfigurationValidationAndHelp/n/n"; descString += "At least one of the following options must be used: -p, -l, -a, -q, or -t/n/n"; descString += "Allowed options:"; boost::program_options::options_description desc(descString); desc.add_options() (kHelpCommandOpt, "produce help message") (kPluginCommandOpt, boost::program_options::value<std::string>(), "only print descriptions for this plugin") (kLibraryCommandOpt, boost::program_options::value<std::string>(), "only print descriptions for plugins in this library") (kAllLibrariesCommandOpt, "allows the program to run without selecting a plugin or library. " "This will take a significant amount of time.") (kModuleLabelCommandOpt, boost::program_options::value<std::string>(), "only print descriptions for this module label") (kBriefCommandOpt, "do not print comments, more compact format, suppress text" " added to help the user understand what the output means") (kPrintOnlyLabelsCommandOpt, "do not print parameter descriptions, just list module labels matching selection criteria") (kPrintOnlyPluginsCommandOpt, "do not print parameter descriptions or module labels, just list plugins matching selection criteria") (kLineWidthCommandOpt, boost::program_options::value<unsigned>(), "try to limit lines to this length by inserting newlines between words in comments. Long words or names can cause the line length to exceed this limit. Defaults to terminal screen width or 80") (kTopLevelCommandOpt, boost::program_options::value<std::string>(), "print only the description for the top level parameter set with this name. Allowed names are 'options', 'maxEvents', 'maxLuminosityBlocks', and 'maxSecondsUntilRampdown'."); boost::program_options::variables_map vm; try { store(boost::program_options::command_line_parser(argc,argv).options(desc).run(),vm); notify(vm); } catch(boost::program_options::error const& iException) { std::cerr << "Exception from command line processing: " << iException.what() << "/n"; std::cerr << desc << std::endl; return 1; } if(vm.count(kHelpOpt)) { std::cout << desc << std::endl; return 0; } std::string plugin; std::string library; std::string moduleLabel; bool brief = false; bool printOnlyLabels = false; bool printOnlyPlugins = false; std::string printOnlyTopLevel; if (vm.count(kPluginOpt)) { plugin = vm[kPluginOpt].as<std::string>(); } if (vm.count(kLibraryOpt)) { library = vm[kLibraryOpt].as<std::string>(); } if (!vm.count(kAllLibrariesOpt)) { if (!vm.count(kPluginOpt) && !vm.count(kLibraryOpt) && !vm.count(kPrintOnlyPluginsOpt) && !vm.count(kTopLevelOpt)) { std::cerr << "/nERROR: At least one of the following options must be used: -p, -l, -a, -q, or -t/n/n"; std::cerr << desc << std::endl; return 1; } } if (vm.count(kModuleLabelOpt)) { moduleLabel = vm[kModuleLabelOpt].as<std::string>(); } if (vm.count(kBriefOpt)) { brief = true; } if (vm.count(kPrintOnlyLabelsOpt)) { printOnlyLabels = true; } if (vm.count(kPrintOnlyPluginsOpt)) { printOnlyPlugins = true; } unsigned lineWidth = 80U;//.........这里部分代码省略.........
开发者ID:Moanwar,项目名称:cmssw,代码行数:101,
示例27: close_store void close_store() { store(outfile); }
开发者ID:ian-bertolacci,项目名称:rose-develop,代码行数:3,
示例28: main_40entry main_40() {new_env(0, 3);ildc(1);newobj(2);ildc(0);call(List_28);store();pop();ildc(0);ildc(1);store();pop();label6:ildc(0);load();ildc(6);ilt();jz(label7);ildc(1);ildc(1);load();ildc(0);load();call(push_front_30);store();pop();label8:ildc(0);dup();load();swap();dup();load();ildc(1);iadd();store();pop();pop();jmp(label6);label7:ildc(1);load();call(print_36);pop();ildc(6);call(print_13);pop();ildc(1);load();call(length_34);call(println_15);pop();ildc(9);call(print_13);pop();ildc(1);load();call(sum_35);call(println_15);pop();ildc(2);newobj(2);ildc(1);load();call(get_element_29);call(List_28);store();pop();ildc(1);ildc(1);load();call(pop_front_33);store();pop();label9:ildc(1);load();null();onotequal();jz(label10);ildc(2);ildc(2);load();ildc(1);load();call(get_element_29);call(push_front_30);store();pop();ildc(1);ildc(1);load();call(pop_front_33);store();pop();jmp(label9);label10:ildc(2);load();call(print_36);//.........这里部分代码省略.........
开发者ID:ksandeep,项目名称:decaf_labs,代码行数:101,
注:本文中的store函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ store32函数代码示例 C++ storage函数代码示例 |