Ignore:
Timestamp:
Mar 12, 2009, 8:01:46 AM (16 years ago)
Author:
Adam Roben
Message:

Adopt setThreadNameInternal on Windows

Also changed a Windows-only assertion about thread name length to an
all-platform log message.

Reviewed by Adam Treat.

  • wtf/Threading.cpp: (WTF::createThread): Warn if the thread name is longer than 31 characters, as Visual Studio will truncate names longer than that length.
  • wtf/ThreadingWin.cpp: (WTF::setThreadNameInternal): Renamed from setThreadName and changed to always operate on the current thread. (WTF::initializeThreading): Changed to use setThreadNameInternal. (WTF::createThreadInternal): Removed call to setThreadName. This is now handled by threadEntryPoint and setThreadNameInternal.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/wtf/ThreadingWin.cpp

    r41605 r41626  
    9999namespace WTF {
    100100
    101 // MS_VC_EXCEPTION, THREADNAME_INFO, and setThreadName all come from <http://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx>.
     101// MS_VC_EXCEPTION, THREADNAME_INFO, and setThreadNameInternal all come from <http://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx>.
    102102static const DWORD MS_VC_EXCEPTION = 0x406D1388;
    103103
     
    111111#pragma pack(pop)
    112112
    113 static void setThreadName(DWORD dwThreadID, LPCSTR szThreadName)
    114 {
    115     // Visual Studio has a 31-character limit on thread names. Longer names will
    116     // be truncated silently, but we'd like callers to know about the limit.
    117     ASSERT_ARG(szThreadName, strlen(szThreadName) <= 31);
    118 
     113void setThreadNameInternal(const char* szThreadName)
     114{
    119115    THREADNAME_INFO info;
    120116    info.dwType = 0x1000;
    121117    info.szName = szThreadName;
    122     info.dwThreadID = dwThreadID;
     118    info.dwThreadID = GetCurrentThreadId();
    123119    info.dwFlags = 0;
    124120
     
    158154        initializeMainThread();
    159155        mainThreadIdentifier = currentThread();
    160         setThreadName(mainThreadIdentifier, "Main Thread");
     156        setThreadNameInternal("Main Thread");
    161157    }
    162158}
     
    221217    }
    222218
    223     if (threadName)
    224         setThreadName(threadIdentifier, threadName);
    225 
    226219    threadID = static_cast<ThreadIdentifier>(threadIdentifier);
    227220    storeThreadHandleByIdentifier(threadIdentifier, threadHandle);
    228221
    229222    return threadID;
    230 }
    231 
    232 void setThreadNameInternal(const char*)
    233 {
    234223}
    235224
Note: See TracChangeset for help on using the changeset viewer.