Beispiel #1
0
bool Thread::IsMainThread()
{
#ifdef URHO3D_THREADING
    return GetCurrentThreadID() == mainThreadID;
#else
    return true;
#endif // URHO3D_THREADING
}
void    OSEventThread::IncreaseWatchNum()
{
    int n = ++mWatchNum;
    if(n == 1 && GetCurrentThreadID() != GetThreadID()){
        //if(NULL != UT_LIST_GET_NEXT(watchNode,&mIdleTimer) || NULL != UT_LIST_GET_PREV(watchNode,&mIdleTimer) )
        //    UT_LIST_REMOVE(watchNode,mTimerList,&mIdleTimer);
        this->Start();
    }
}
Beispiel #3
0
bool Thread::IsMainThread()
{
    return GetCurrentThreadID() == mainThreadID;
}
Beispiel #4
0
void Thread::SetMainThread()
{
    mainThreadID = GetCurrentThreadID();
}
Beispiel #5
0
    void Thread::ThreadBody()
    {
        Utils::ThreadNamesLocker locker(GetCurrentThreadID(), m_name);

        run();  // run user code
    }
Beispiel #6
0
const char *RageThread::GetCurThreadName()
{
	return GetThreadNameByID( GetCurrentThreadID() );
}
Beispiel #7
0
/** No descriptions */
void Profiler::ThreadResume()
{
  //cout << "ThreadResume( " << GetCurrentThreadID() << " )" << endl;
  _tic.GetThreadInfo( GetCurrentThreadID() )->GetStackInfo()->ResumeFunction( rdtsc() );
}
Beispiel #8
0
/** No descriptions */
void Profiler::ThreadSuspend()
{
  //cout << "ThreadSuspend( " << GetCurrentThreadID() << " )" << endl;
  _tic.GetThreadInfo( GetCurrentThreadID() )->GetStackInfo()->SuspendFunction( rdtsc() );
}
Beispiel #9
0
/** No descriptions */
ThreadInfo* Profiler::GetCurrentThreadInfo()
{
  return _tic.GetThreadInfo( GetCurrentThreadID() );
}
Beispiel #10
0
void OSEventThread::Entry()
{
    int n;
    fd_set rfds;
    struct timeval tv;
    struct timeval * ptv = NULL;

    ULONG lasttime = OS::GetTickCount();
    ULONG currtime = lasttime;

    init_wakeuper();

    while (!IsStopRequested()) {

        //10 check time rollback
        lasttime = currtime;
        currtime = OS::GetTickCount();
        if(currtime < lasttime) {
            rollback_timer(currtime);
            firePending();
        }

        //20 calc timeout
        if (-1 == calcNextTimeout(&tv,currtime)) {
            // no pending timers; block indefinitely
            TRACE("~~~~ no timers; blocking indefinitely ~~~~\n");
            ptv = NULL;
        } else {
            TRACE("~~~~ blocking for %ds + %dus ~~~~\n", (int)tv.tv_sec, (int)tv.tv_usec);
            ptv = &tv;
        }

        //30 make local copy of read fd_set
        memcpy(&rfds, &mReadFds, sizeof(fd_set));

        //40 select
        n = select(mMaxfFd, &rfds, NULL, NULL, ptv);

        TRACE("~~~~ %d events fired ~~~~\n", n);
        
        if(n > 0){

            //50 Check for read-ready
            processReadReadies(&rfds, n);

        }else if(n == 0){

            //60 Check for timeouts
            processTimeouts();

        }else{

            //70 check error
            int err = OSThread::GetErrno();
            switch(err)
            {
            case EINTR:
                continue;
            case EBADF:
                WARN("event_req: EBADF\n");
				continue;
            case ENOTCONN:
                ERR("event_req: ENOTCONN\n");
                continue;
            default:
                ERR("event_req: select error (%d)\n", err);
                ASSERT_C(0);
                return;
            }
        }


        //80 Fire away
        firePending();
    }

    uninit_wakeuper();

    TRACE("~~~~ Thread exit:%x ~~~~\n",(unsigned int)GetCurrentThreadID());
}