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


C++ ThreadInfo类代码示例

本文整理汇总了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);
}
开发者ID:,项目名称:,代码行数:29,代码来源:

示例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;
}
开发者ID:gjmurakami-10gen,项目名称:congo,代码行数:30,代码来源:ThreadPosix.c

示例3: ThreadCallbackWrapper

static void ThreadCallbackWrapper(void *context)
{
    ThreadInfo *threadInfo = (ThreadInfo*)context;
    if (threadInfo)
    threadInfo->Runnable(threadInfo, threadInfo->Context);
    vTaskDelete(NULL);
}
开发者ID:CreatorDev,项目名称:creator-wifire-app,代码行数:7,代码来源:threads.c

示例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;
            }
        }
    }
}
开发者ID:heyfluke,项目名称:gen-trace,代码行数:31,代码来源:runtime_sigprof.cpp

示例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
}
开发者ID:valenting,项目名称:gecko-dev,代码行数:31,代码来源:GeckoSampler.cpp

示例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
}
开发者ID:valenting,项目名称:gecko-dev,代码行数:30,代码来源:GeckoSampler.cpp

示例7: entry_point

static DWORD WINAPI entry_point(void *parameter)
{
	ThreadInfo *ti = static_cast<ThreadInfo *>(parameter);
	ti->entry(ti->param);
	delete ti;
	return 0;
}
开发者ID:DeathBlade,项目名称:Navn,代码行数:7,代码来源:pthread.cpp

示例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);
		}
开发者ID:HaikuArchives,项目名称:BeServed,代码行数:11,代码来源:MyNetApp.cpp

示例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 );
}
开发者ID:Vivek-sagar,项目名称:moose-1,代码行数:11,代码来源:main.cpp

示例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;
}
开发者ID:AnsonX10,项目名称:bitfighter,代码行数:10,代码来源:streamplay.cpp

示例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);
}
开发者ID:,项目名称:,代码行数:53,代码来源:

示例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();
}
开发者ID:,项目名称:,代码行数:16,代码来源:

示例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();
    }
开发者ID:HanumathRao,项目名称:ARTSynchronized,代码行数:32,代码来源:N.cpp

示例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();
    }
开发者ID:HanumathRao,项目名称:ARTSynchronized,代码行数:32,代码来源:N.cpp

示例15: UpdateCountdown

DWORD WINAPI UpdateCountdown(LPVOID _lpParamter)
{
	ThreadInfo* Info = (ThreadInfo*)_lpParamter;
	LARGE_INTEGER pcFreq, currentTick;

	if(!QueryPerformanceFrequency(&pcFreq))
	{	
		//Todo: Insert Error Code
	}

	if(!QueryPerformanceCounter(&currentTick))
	{	
		//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(&currentTick);
		
		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;
}
开发者ID:slavoski,项目名称:Falco,代码行数:46,代码来源:Timer.cpp


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