本文整理汇总了C++中ThreadInfo类的典型用法代码示例。如果您正苦于以下问题:C++ ThreadInfo类的具体用法?C++ ThreadInfo怎么用?C++ ThreadInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ThreadInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Lock
void ThreadPool::shutDown() {
Lock(poolLock);
ThreadInfo *p;
// note: do not terminate thread 0 (main thread) in this loop
for (unsigned i = 1; i < nThreads; i++) {
p = data[i];
// All threads should be idle when this function is called.
if (p->state == ThreadInfo::Idle) {
// Set the thread to the terminating state that will force thread
// procedure exit
p->state = ThreadInfo::Terminating;
// unblock the thread
p->signal();
}
// wait for the thread to terminate
#ifdef _WIN32
WaitForSingleObject(p->thread_id,INFINITE);
#else
void *value_ptr;
pthread_join(p->thread_id,&value_ptr);
#endif
// Free thread data
delete p;
}
// now free main thread data
delete data[0]->work;
delete data[0]; // main thread structure
Unlock(poolLock);
}
示例2: Thread_Worker
static void *
Thread_Worker (void *data) /* IN */
{
ThreadInfo *info = data;
sigset_t set;
void *ret;
ASSERT (info);
ASSERT (info->func);
sigfillset (&set);
pthread_sigmask (SIG_BLOCK, &set, NULL);
#if defined(HAVE_PTHREAD_SETNAME_NP)
if (info->name) {
#if defined(PLATFORM_APPLE)
pthread_setname_np (info->name);
#elif defined(PLATFORM_LINUX)
pthread_setname_np (pthread_self (), info->name);
#endif
}
#endif
ret = info->func (info->data);
free (info->name);
free (info);
return ret;
}
示例3: ThreadCallbackWrapper
static void ThreadCallbackWrapper(void *context)
{
ThreadInfo *threadInfo = (ThreadInfo*)context;
if (threadInfo)
threadInfo->Runnable(threadInfo, threadInfo->Context);
vTaskDelete(NULL);
}
示例4: __end_ctrace__
void
__end_ctrace__ (CTraceStruct *c, const char *name)
{
if (file_to_write == 0)
return;
ThreadInfo *tinfo = GetThreadInfo ();
tinfo->stack_end_--;
if (tinfo->stack_end_ < ThreadInfo::max_stack)
{
if (c->start_time_ != invalid_time)
{
if (tinfo->stack_end_ == 0)
{
tinfo->UpdateCurrentTime ();
c->min_end_time_ = tinfo->current_time_ + ticks;
}
// we should record this
RecordThis (c, tinfo);
if (tinfo->stack_end_ != 0)
{
// propagate the back's mini end time
tinfo->stack_[tinfo->stack_end_ - 1]->min_end_time_
= c->min_end_time_ + ticks;
tinfo->stack_[tinfo->stack_end_ - 1]->min_end_time_thread_
= c->min_end_time_thread_ + ticks;
tinfo->current_time_ += ticks;
tinfo->current_time_thread_ += ticks;
}
}
}
}
示例5: Stop
GeckoSampler::~GeckoSampler()
{
if (IsActive())
Stop();
SetActiveSampler(nullptr);
// Destroy ThreadProfile for all threads
{
::MutexAutoLock lock(*sRegisteredThreadsMutex);
for (uint32_t i = 0; i < sRegisteredThreads->size(); i++) {
ThreadInfo* info = sRegisteredThreads->at(i);
ThreadProfile* profile = info->Profile();
if (profile) {
delete profile;
info->SetProfile(nullptr);
}
// We've stopped profiling. We no longer need to retain
// information for an old thread.
if (info->IsPendingDelete()) {
delete info;
sRegisteredThreads->erase(sRegisteredThreads->begin() + i);
i--;
}
}
}
#if defined(XP_WIN)
delete mIntelPowerGadget;
#endif
}
示例6: data
void GeckoSampler::StreamTaskTracer(SpliceableJSONWriter& aWriter)
{
#ifdef MOZ_TASK_TRACER
aWriter.StartArrayProperty("data");
nsAutoPtr<nsTArray<nsCString>> data(mozilla::tasktracer::GetLoggedData(sStartTime));
for (uint32_t i = 0; i < data->Length(); ++i) {
aWriter.StringElement((data->ElementAt(i)).get());
}
aWriter.EndArray();
aWriter.StartArrayProperty("threads");
::MutexAutoLock lock(*sRegisteredThreadsMutex);
for (size_t i = 0; i < sRegisteredThreads->size(); i++) {
// Thread meta data
ThreadInfo* info = sRegisteredThreads->at(i);
aWriter.StartObjectElement();
if (XRE_GetProcessType() == GeckoProcessType_Plugin) {
// TODO Add the proper plugin name
aWriter.StringProperty("name", "Plugin");
} else {
aWriter.StringProperty("name", info->Name());
}
aWriter.IntProperty("tid", static_cast<int>(info->ThreadId()));
aWriter.EndObject();
}
aWriter.EndArray();
aWriter.DoubleProperty("start", static_cast<double>(mozilla::tasktracer::GetStartTime()));
#endif
}
示例7: entry_point
static DWORD WINAPI entry_point(void *parameter)
{
ThreadInfo *ti = static_cast<ThreadInfo *>(parameter);
ti->entry(ti->param);
delete ti;
return 0;
}
示例8: AddCLVItems
// AddCLVItems()
//
void AddCLVItems(ColumnListView* MyColumnListView)
{
extern int32 getShares(void *);
ThreadInfo *info = new ThreadInfo();
info->SetColumnListView(MyColumnListView);
info->SetHostAddress(address);
thread_id shareThread = spawn_thread(getShares, "Get Shares", B_NORMAL_PRIORITY, info);
resume_thread(shareThread);
}
示例9: barrierLoop
/// This is the function that happens on each thread if it is a sustained
/// thread, using barriers to synchronize.
void* barrierLoop( void* info )
{
ThreadInfo* t = reinterpret_cast< ThreadInfo* >( info );
for ( int i = 0; i < t->numJoins(); ++i ) {
barrier->wait();
busyFunc( t );
}
pthread_exit( NULL );
}
示例10: StarterFunc
static DWORD CALLBACK StarterFunc(void *ptr)
{
ThreadInfo *inf = (ThreadInfo*)ptr;
ALint ret;
ret = inf->func(inf->ptr);
ExitThread((DWORD)ret);
return (DWORD)ret;
}
示例11: mozilla_sampler_start
// Values are only honored on the first start
void mozilla_sampler_start(int aProfileEntries, int aInterval,
const char** aFeatures, uint32_t aFeatureCount)
{
if (!stack_key_initialized)
profiler_init();
/* If the sampling interval was set using env vars, use that
in preference to anything else. */
if (sUnwindInterval > 0)
aInterval = sUnwindInterval;
PseudoStack *stack = tlsPseudoStack.get();
if (!stack) {
ASSERT(false);
return;
}
// Reset the current state if the profiler is running
profiler_stop();
TableTicker* t;
if (sps_version2()) {
t = new BreakpadSampler(aInterval ? aInterval : PROFILE_DEFAULT_INTERVAL,
aProfileEntries ? aProfileEntries : PROFILE_DEFAULT_ENTRY,
aFeatures, aFeatureCount);
} else {
t = new TableTicker(aInterval ? aInterval : PROFILE_DEFAULT_INTERVAL,
aProfileEntries ? aProfileEntries : PROFILE_DEFAULT_ENTRY,
aFeatures, aFeatureCount);
}
tlsTicker.set(t);
t->Start();
if (t->ProfileJS()) {
mozilla::MutexAutoLock lock(*Sampler::sRegisteredThreadsMutex);
std::vector<ThreadInfo*> threads = t->GetRegisteredThreads();
for (uint32_t i = 0; i < threads.size(); i++) {
ThreadInfo* info = threads[i];
ThreadProfile* thread_profile = info->Profile();
if (!thread_profile) {
continue;
}
thread_profile->GetPseudoStack()->enableJSSampling();
}
}
sIsProfiling = true;
nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
if (os)
os->NotifyObservers(nullptr, "profiler-started", nullptr);
}
示例12: stopThreadByInfo
// Stops a thread at the scheduler by means of @ref ThreadInfo object
void Scheduler::stopThreadByInfo(const ThreadInfo& info)
{
if (info.getThread() == NULL)
{
return;
}
if (info.getThread()->isStopped())
return; // has been stopped
info.getThread()->stop();
// join
info.join();
}
示例13: insertGrow
void N::insertGrow(curN *n, uint64_t v, N *parentNode, uint64_t parentVersion, uint8_t keyParent, uint8_t key, N *val, bool &needRestart, ThreadInfo &threadInfo) {
if (!n->isFull()) {
if (parentNode != nullptr) {
parentNode->readUnlockOrRestart(parentVersion, needRestart);
if (needRestart) return;
}
n->upgradeToWriteLockOrRestart(v, needRestart);
if (needRestart) return;
n->insert(key, val);
n->writeUnlock();
return;
}
parentNode->upgradeToWriteLockOrRestart(parentVersion, needRestart);
if (needRestart) return;
n->upgradeToWriteLockOrRestart(v, needRestart);
if (needRestart) {
parentNode->writeUnlock();
return;
}
auto nBig = new biggerN(n->getPrefix(), n->getPrefixLength());
n->copyTo(nBig);
nBig->insert(key, val);
N::change(parentNode, keyParent, nBig);
n->writeUnlockObsolete();
threadInfo.getEpoche().markNodeForDeletion(n, threadInfo);
parentNode->writeUnlock();
}
示例14: removeAndShrink
void N::removeAndShrink(curN *n, uint64_t v, N *parentNode, uint64_t parentVersion, uint8_t keyParent, uint8_t key, bool &needRestart, ThreadInfo &threadInfo) {
if (!n->isUnderfull() || parentNode == nullptr) {
if (parentNode != nullptr) {
parentNode->readUnlockOrRestart(parentVersion, needRestart);
if (needRestart) return;
}
n->upgradeToWriteLockOrRestart(v, needRestart);
if (needRestart) return;
n->remove(key);
n->writeUnlock();
return;
}
parentNode->upgradeToWriteLockOrRestart(parentVersion, needRestart);
if (needRestart) return;
n->upgradeToWriteLockOrRestart(v, needRestart);
if (needRestart) {
parentNode->writeUnlock();
return;
}
auto nSmall = new smallerN(n->getPrefix(), n->getPrefixLength());
n->copyTo(nSmall);
nSmall->remove(key);
N::change(parentNode, keyParent, nSmall);
n->writeUnlockObsolete();
threadInfo.getEpoche().markNodeForDeletion(n, threadInfo);
parentNode->writeUnlock();
}
示例15: UpdateCountdown
DWORD WINAPI UpdateCountdown(LPVOID _lpParamter)
{
ThreadInfo* Info = (ThreadInfo*)_lpParamter;
LARGE_INTEGER pcFreq, currentTick;
if(!QueryPerformanceFrequency(&pcFreq))
{
//Todo: Insert Error Code
}
if(!QueryPerformanceCounter(¤tTick))
{
//Todo: Insert Error Code
}
double startTime = double(currentTick.QuadPart) / double(pcFreq.QuadPart);
//convert to milliseconds
double countdown = Info->time / 1000.0;
double lastTime = 0;
//loop forever
// or until the time is 0 or below 0
while(true)
{
QueryPerformanceCounter(¤tTick);
double currTime = (double(currentTick.QuadPart) / double(pcFreq.QuadPart)) - startTime;
countdown -= (currTime - lastTime);
lastTime = currTime;
//Are we ready to break?
if(countdown <= 0.0)
break;
}
//Call the function
Info->function();
//Delete the memory we allocated
delete Info;
return 0;
}