这篇教程C++ th函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中th函数的典型用法代码示例。如果您正苦于以下问题:C++ th函数的具体用法?C++ th怎么用?C++ th使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了th函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: testThreadsstatic void testThreads( const char* testname, int times){ int ti = 0, te = times; for (; ti != te; ++ti) { int start = ti + 1000 + 1; int nofThreads = ti*10; std::cerr << "starting test " << testname << "." << ti << " (" << (2*nofThreads) << " threads ..." << std::endl; GlobalCounter obj( start); std::vector<strus::shared_ptr<strus::thread> > threadGroup; for (int si=0; si <= nofThreads; ++si) { strus::shared_ptr<strus::thread> th( new strus::thread( &GlobalCounter::run, &obj, ti * 1000, si)); threadGroup.push_back( th); } for (int si=0; si <= nofThreads; ++si) { strus::shared_ptr<strus::thread> th( new strus::thread( &GlobalCounter::run, &obj, ti * 1000, -si)); threadGroup.push_back( th); } std::cerr << "waiting for threads to terminate ..." << std::endl; std::vector<strus::shared_ptr<strus::thread> >::iterator gi = threadGroup.begin(), ge = threadGroup.end(); for (; gi != ge; ++gi) { (*gi)->join(); } std::cerr << "done" << std::endl; obj.checkCounter( start); }}
开发者ID:patrickfrey,项目名称:strusBase,代码行数:31,
示例2: thvoid th(int n, char a, char b, char c){ if (n == 1) { printf("/n Move disk 1 from %c to %c",a,c); return; } th(n-1,a,b,c); printf("/n Move disk %d from %c to %c",n,a,c); th(n-1,a,b,c);}
开发者ID:surya200196,项目名称:surya,代码行数:11,
示例3: __treecopy/* treecopy assumes that n[0-n] is filled with zeros*/ void __treecopy(caps_t o, struct _XTreeHandle *n, int len, unsigned int tid, struct hashtable **h) { int i; //initialize fresh memory memset(n,0,len*sizeof(struct _XTreeHandle)); // create new tree with the appropriate capabilities for(i=0;i<len;i++) { struct _XTreeHandle *t = th(o,i); n[i].caps.rcnt = o[i].rc; n[i].caps.wr_cnt = o[i].wc; n[i].caps.rd_cnt= o[i].lc; n[i].h = t->h; hashtable_insert(h,n+i); // create mapping //increment ref count of this region __sync_fetch_and_add(&t->h->caps.rcnt,1); t->h->single_thread_key = 0; //not thread local if(o[i].wc) { // transfer writer capabilities if( tcb()->tid == t->h->caps.writer_cv) { t->h->caps.writer_cv = tid; } else errquit("_treecopy: writer_cv"); } //if there exist read capabilities, increment read count if(o[i].lc) __sync_fetch_and_add(&t->h->caps.rd_cnt,1);#ifdef __RUNTIME_MEMORY_DEBUG_LOCKOP print_xtree(n+i,0);#endif struct _XTreeHandle *parent= t->parent_key; int idx; if(parent) for(idx=0;idx<len && th(o,idx) != parent;idx++); else idx = len; if(idx < len) { n[i].parent_key = n + idx; n[i].next_key = n[idx].sub_keys; n[idx].sub_keys = n + i; } else n[i].parent_key = 0; } //remove capabilities transferred from this tree //start off child nodes so that we don't bump into //a deallocated node (if a parent gets deallocated //its subregions are also removed). Notice that the //array "o" is already sorted in the natural //allocation order. for(i=len-1;i>-1;i--) _xregion_cap_th(-o[i].rc,-o[i].wc,-o[i].lc,th(o,i));}
开发者ID:pgerakios,项目名称:Concurrent-Cyclone-with-inference,代码行数:55,
示例4: concurrent_locksvoid VM_ThreadDump::doit() { ResourceMark rm; ConcurrentLocksDump concurrent_locks(true); if (_with_locked_synchronizers) { concurrent_locks.dump_at_safepoint(); } if (_num_threads == 0) { // Snapshot all live threads for (JavaThread* jt = Threads::first(); jt != NULL; jt = jt->next()) { if (jt->is_exiting() || jt->is_hidden_from_external_view()) { // skip terminating threads and hidden threads continue; } ThreadConcurrentLocks* tcl = NULL; if (_with_locked_synchronizers) { tcl = concurrent_locks.thread_concurrent_locks(jt); } ThreadSnapshot* ts = snapshot_thread(jt, tcl); _result->add_thread_snapshot(ts); } } else { // Snapshot threads in the given _threads array // A dummy snapshot is created if a thread doesn't exist for (int i = 0; i < _num_threads; i++) { instanceHandle th = _threads->at(i); if (th() == NULL) { // skip if the thread doesn't exist // Add a dummy snapshot _result->add_thread_snapshot(new ThreadSnapshot()); continue; } // Dump thread stack only if the thread is alive and not exiting // and not VM internal thread. JavaThread* jt = java_lang_Thread::thread(th()); if (jt == NULL || /* thread not alive */ jt->is_exiting() || jt->is_hidden_from_external_view()) { // add a NULL snapshot if skipped _result->add_thread_snapshot(new ThreadSnapshot()); continue; } ThreadConcurrentLocks* tcl = NULL; if (_with_locked_synchronizers) { tcl = concurrent_locks.thread_concurrent_locks(jt); } ThreadSnapshot* ts = snapshot_thread(jt, tcl); _result->add_thread_snapshot(ts); } }}
开发者ID:stkaushal,项目名称:jdk8_tl,代码行数:54,
示例5: __Call_thlong __Call_th( CDSR_VMEval& /*vm*/, MMD_Address& addr, UniWord *arg ){#if _DEBUG if( addr.param2 < 0 ) throw _T("__Call_(fun) : internal error, out of range");#endif if( addr.param2 == 0 ) // DSRDATA_TYPE_REAL *(arg - 1) = CDSRReal( th( (arg - 1)->getReal() ) ); else // DSRDATA_TYPE_COMPLEX *(arg - 1) = CDSRComplex( th( (arg - 1)->getComplex() ) ); return 1 - addr.param3;}
开发者ID:Nilis640,项目名称:formulator-mathml,代码行数:12,
示例6: TYPED_TESTTYPED_TEST(ThreadSpecificTest, OhterThread){ this->helper_.assign(1); std::thread th(&TestFixture::helper_type::make_and_assign, &this->helper_, 2); th.join(); ASSERT_TRUE(this->helper_.equal(1));}
开发者ID:seto1221,项目名称:slib,代码行数:7,
示例7: Defaultvoid CRichEditNcBorder::NcDrawBorder(){ Default(); if (m_bThemedBorder) { CThemed th(GetCWnd(), WC_EDIT); CWindowDC dc(GetCWnd()); CRect rBorder, rClient; GetWindowRect(rBorder); th.GetThemeBackgroundContentRect(&dc, EP_EDITTEXT, ETS_NORMAL, rBorder, rClient); // convert to window coordinates rClient.OffsetRect(-rBorder.left, -rBorder.top); rBorder.OffsetRect(-rBorder.left, -rBorder.top); dc.ExcludeClipRect(rClient); // determine the current border state int nState; if (!IsWindowEnabled()) nState = ETS_DISABLED; else if (HasStyle(ES_READONLY) || SendMessage(EM_GETOPTIONS, NULL, NULL) & ECO_READONLY) nState = ETS_READONLY; else nState = ETS_NORMAL; th.DrawBackground(&dc, EP_EDITTEXT, nState, rBorder); }}
开发者ID:Fox-Heracles,项目名称:TodoList,代码行数:35,
示例8: thvoid testObj::test<1>(void){ Thread th( (SyncThread(s_)) ); usleep(100*1000); s_.start(); s_.waitForDone();}
开发者ID:el-bart,项目名称:ACARM-ng,代码行数:7,
示例9: printfint KiekkoNetwork::Update(int threadCount){ if (listen(ListenSocket, SOMAXCONN) == SOCKET_ERROR) { int errsave = errno; printf("listen(...) failed! Error code : %d/n", errsave); return 0; } ClientSocket = INVALID_SOCKET; ClientSocket = accept(ListenSocket, 0, 0); if (ClientSocket == INVALID_SOCKET) { printf("accept(...) failed! Error code : EI KINOSTA/n"); return 0; } recvThreadMutex.lock(); std::thread th(NewClient, ClientSocket, threadCount); th.detach(); SendPackage temp = { 0, 0, 0, 0, 0 }; paskafix = true; SendMsg(temp); return 1;}
开发者ID:Ikutzu,项目名称:Kiekkopeli,代码行数:27,
示例10: TESTTEST(EventLoop, invoke) { auto loop = std::make_shared<capnqml::EventLoop>(); bool invoked = false; bool handler_called = false; loop->setHandler([&](auto m) -> decltype (auto) { handler_called = true; return nullptr; }); loop->invoke([&]() { invoked = true; capnqml::Message msg; loop->push(std::move(msg)); }); ASSERT_EQ(loop->state(), capnqml::EventLoop::State::Startup); // NOLINT std::thread th([=] { loop->run(); // NOLINT }); th.detach(); std::this_thread::sleep_for(std::chrono::milliseconds(100)); ASSERT_EQ(loop->state(), capnqml::EventLoop::State::Idle); // NOLINT loop->cancel(); std::this_thread::sleep_for(std::chrono::milliseconds(100)); ASSERT_EQ(loop->state(), capnqml::EventLoop::State::Canceled); ASSERT_TRUE(invoked); ASSERT_TRUE(handler_called);}
开发者ID:raffber,项目名称:capnqml,代码行数:26,
示例11: ReportMessage void ReportMessage(const char *message, ...) { if (!IsEnabled() || CheckSpamLimited()) return; int pos = NextFreePos(); if (pos == -1) return; const int MESSAGE_BUFFER_SIZE = 65536; char temp[MESSAGE_BUFFER_SIZE]; va_list args; va_start(args, message); vsnprintf(temp, MESSAGE_BUFFER_SIZE - 1, message, args); temp[MESSAGE_BUFFER_SIZE - 1] = '/0'; va_end(args); Payload &payload = payloadBuffer[pos]; payload.type = RequestType::MESSAGE; payload.string1 = message; payload.string2 = temp; std::thread th(Process, pos); th.detach(); }
开发者ID:makotech222,项目名称:ppsspp,代码行数:25,
示例12: tmr_poll/** * Poll all timers in the current thread * * @param tmrl Timer list */void tmr_poll(struct list *tmrl){ const uint64_t jfs = tmr_jiffies(); for (;;) { struct tmr *tmr; tmr_h *th; void *th_arg; tmr = list_ledata(tmrl->head); if (!tmr || (tmr->jfs > jfs)) { break; } th = tmr->th; th_arg = tmr->arg; tmr->th = NULL; list_unlink(&tmr->le); if (!th) continue;#if TMR_DEBUG call_handler(th, th_arg);#else th(th_arg);#endif }}
开发者ID:soramimi,项目名称:qSIP,代码行数:37,
示例13: SetIconBOOL Ccoin_lookerDlg::OnInitDialog(){ CDialogEx::OnInitDialog(); // 设置此对话框的图标。当应用程序主窗口不是对话框时,框架将自动 // 执行此操作 SetIcon(m_hIcon, TRUE); // 设置大图标 SetIcon(m_hIcon, FALSE); // 设置小图标 // TODO: 在此添加额外的初始化代码 auto g_CoinList = LoadCoinList(GetAppDir()); if (g_CoinList.size()) { int idx = 0; for (auto it = g_CoinList.begin(); it != g_CoinList.end(); ++it) { shared_ptr<ICoinOption> pCoinOption = *it; shared_ptr<IUserContext> pWork = create_coin_work(pCoinOption); boost::thread th(boost::bind(&IUserContext::load_db, pWork)); shared_ptr<CRecvDialog> pDlg(new CRecvDialog(pWork, &m_tab1)); pDlg->Create(CRecvDialog::IDD); CRect r; pDlg->GetWindowRect(r); r.top += 18; r.left += 14; pDlg->MoveWindow(r); m_tab1.InsertItem(m_tab1.GetItemCount(), pCoinOption->prev_name.c_str()); m_vlist.push_back(pDlg); } m_vlist[0]->ShowWindow(SW_SHOW); } return TRUE; // 除非将焦点设置到控件,否则返回 TRUE}
开发者ID:RelicOfTesla,项目名称:coin_looker,代码行数:35,
示例14: newtail_mainintnewtail_main( int argc, char ** argv ){ char pidfile[80]; sprintf( pidfile, PIDFILE, getenv( "HOME" )); if ( argc == 2 && strcmp( argv[1], "-q" ) == 0 ) { unlink( pidfile ); return 0; } num_tail_threads = 0; ThreadParams p; p.my_eid = 1; Threads th( &p ); while ( argc > 1 ) { (void) new NewTailThread( argv[1] ); argc--; argv++; } newtail_die = false; (void) new MonitorThread( pidfile ); th.loop(); return 0;}
开发者ID:flipk,项目名称:pfkutils,代码行数:30,
示例15: qDebug/** Submit a traceroute formatted as HTTP POST data to the server. */bool ServerComm::submitTraceroute(const char *post_data, TrStatus *tstat, bool popupOnError) { bool submitted_ok = true; qDebug() << post_data; TrHttp th("trgen.ixmaps.ca", post_data, tstat); subm_waiting_completion = true; connect(&th, SIGNAL(done(bool)), this, SLOT(trResultsSubmitted(bool))); QTime dieTime = QTime::currentTime().addSecs(5); while( QTime::currentTime() < dieTime ) { QCoreApplication::processEvents(QEventLoop::AllEvents, 100); if ( !subm_waiting_completion ) { break; } } if ( subm_waiting_completion ) { if ( popupOnError ) { QMessageBox::critical(owner, tr("Connection failure"), tr("The connection to the central database is not working."), QMessageBox::Ok); } tstat->setError(TrStatus::ERR_SUBMIT_TIMEOUT); submitted_ok = false; } else { //qDebug() << "TrHttp error " << th.error(); QHttp::Error err = th.error(); if ( err != QHttp::NoError ) { tstat->setError(msgConnFailure(err, popupOnError)); submitted_ok = false; } } qDebug() << "posting, state " << th.state() << ", error " << th.error(); qDebug() << "TID=" << tstat->traceroute_id << ", errorMsg=" << tstat->errorMsg; return submitted_ok;}
开发者ID:ixmaps,项目名称:trgen,代码行数:35,
示例16: SetSequenceFilename |