Changeset 41605 in webkit for trunk/JavaScriptCore


Ignore:
Timestamp:
Mar 11, 2009, 6:26:55 PM (16 years ago)
Author:
Darin Adler
Message:

2009-03-11 Darin Adler <Darin Adler>

Reviewed by Mark Rowe.

Give threads names on platforms with pthread_setname_np.

  • wtf/Threading.cpp: (WTF::NewThreadContext::NewThreadContext): Initialize thread name. (WTF::threadEntryPoint): Call setThreadNameInternal. (WTF::createThread): Pass thread name.
  • wtf/Threading.h: Added new comments, setThreadNameInternal.
  • wtf/ThreadingGtk.cpp: (WTF::setThreadNameInternal): Added. Empty.
  • wtf/ThreadingNone.cpp: (WTF::setThreadNameInternal): Added. Empty.
  • wtf/ThreadingPthreads.cpp: (WTF::setThreadNameInternal): Call pthread_setname_np when available.
  • wtf/ThreadingQt.cpp: (WTF::setThreadNameInternal): Added. Empty.
  • wtf/ThreadingWin.cpp: (WTF::setThreadNameInternal): Added. Empty.
Location:
trunk/JavaScriptCore
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r41594 r41605  
     12009-03-11  Darin Adler  <[email protected]>
     2
     3        Reviewed by Mark Rowe.
     4
     5        Give threads names on platforms with pthread_setname_np.
     6
     7        * wtf/Threading.cpp:
     8        (WTF::NewThreadContext::NewThreadContext): Initialize thread name.
     9        (WTF::threadEntryPoint): Call setThreadNameInternal.
     10        (WTF::createThread): Pass thread name.
     11
     12        * wtf/Threading.h: Added new comments, setThreadNameInternal.
     13
     14        * wtf/ThreadingGtk.cpp:
     15        (WTF::setThreadNameInternal): Added. Empty.
     16        * wtf/ThreadingNone.cpp:
     17        (WTF::setThreadNameInternal): Added. Empty.
     18        * wtf/ThreadingPthreads.cpp:
     19        (WTF::setThreadNameInternal): Call pthread_setname_np when available.
     20        * wtf/ThreadingQt.cpp:
     21        (WTF::setThreadNameInternal): Added. Empty.
     22        * wtf/ThreadingWin.cpp:
     23        (WTF::setThreadNameInternal): Added. Empty.
     24
    1252009-03-11  Adam Roben  <[email protected]>
    226
  • trunk/JavaScriptCore/wtf/Threading.cpp

    r40169 r41605  
    11/*
    2  * Copyright (C) 2008 Apple Inc. All rights reserved.
     2 * Copyright (C) 2008, 2009 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    3030
    3131struct NewThreadContext {
    32     NewThreadContext(ThreadFunction entryPoint, void* data)
     32    NewThreadContext(ThreadFunction entryPoint, void* data, const char* name)
    3333        : entryPoint(entryPoint)
    3434        , data(data)
    35     { }
     35        , name(name)
     36    {
     37    }
    3638
    3739    ThreadFunction entryPoint;
    3840    void* data;
     41    const char* name;
    3942
    4043    Mutex creationMutex;
     
    4447{
    4548    NewThreadContext* context = reinterpret_cast<NewThreadContext*>(contextData);
     49
     50    setThreadNameInternal(context->name);
    4651
    4752    // Block until our creating thread has completed any extra setup work
     
    6065ThreadIdentifier createThread(ThreadFunction entryPoint, void* data, const char* name)
    6166{
    62     NewThreadContext* context = new NewThreadContext(entryPoint, data);
     67    NewThreadContext* context = new NewThreadContext(entryPoint, data, name);
    6368
    6469    // Prevent the thread body from executing until we've established the thread identifier
  • trunk/JavaScriptCore/wtf/Threading.h

    r41536 r41605  
    109109typedef void* (*ThreadFunction)(void* argument);
    110110
    111 // Returns 0 if thread creation failed
     111// Returns 0 if thread creation failed.
     112// The thread name must be a literal since on some platforms it's passed in to the thread.
    112113ThreadIdentifier createThread(ThreadFunction, void*, const char* threadName);
     114
     115// Internal platform-specific createThread implementation.
    113116ThreadIdentifier createThreadInternal(ThreadFunction, void*, const char* threadName);
     117
     118// Called in the thread during initialization.
     119// Helpful for platforms where the thread name must be set from within the thread.
     120void setThreadNameInternal(const char* threadName);
    114121
    115122ThreadIdentifier currentThread();
  • trunk/JavaScriptCore/wtf/ThreadingGtk.cpp

    r39908 r41605  
    139139}
    140140
     141void setThreadNameInternal(const char*)
     142{
     143}
     144
    141145int waitForThreadCompletion(ThreadIdentifier threadID, void** result)
    142146{
  • trunk/JavaScriptCore/wtf/ThreadingNone.cpp

    r39908 r41605  
    3535void initializeThreading() { }
    3636ThreadIdentifier createThreadInternal(ThreadFunction, void*, const char*) { return 0; }
     37void setThreadNameInternal(const char*) { }
    3738int waitForThreadCompletion(ThreadIdentifier, void**) { return 0; }
    3839void detachThread(ThreadIdentifier) { }
  • trunk/JavaScriptCore/wtf/ThreadingPthreads.cpp

    r40811 r41605  
    11/*
    2  * Copyright (C) 2007 Apple Inc. All rights reserved.
     2 * Copyright (C) 2007, 2009 Apple Inc. All rights reserved.
    33 * Copyright (C) 2007 Justin Haygood ([email protected])
    44 *
     
    2727 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2828 */
     29
    2930#include "config.h"
    3031#include "Threading.h"
    31 
    32 #include "StdLibExtras.h"
    3332
    3433#if USE(PTHREADS)
     
    3837#include "MainThread.h"
    3938#include "RandomNumberSeed.h"
    40 
     39#include "StdLibExtras.h"
     40#include "UnusedParam.h"
    4141#include <errno.h>
    4242#include <limits.h>
     
    134134{
    135135    pthread_t threadHandle;
    136     if (pthread_create(&threadHandle, NULL, entryPoint, data)) {
     136    if (pthread_create(&threadHandle, 0, entryPoint, data)) {
    137137        LOG_ERROR("Failed to create pthread at entry point %p with data %p", entryPoint, data);
    138138        return 0;
     
    140140
    141141    return establishIdentifierForPthreadHandle(threadHandle);
     142}
     143
     144void setThreadNameInternal(const char* threadName)
     145{
     146#if PLATFORM(DARWIN) && !defined(BUILDING_ON_TIGER) && !defined(BUILDING_ON_LEOPARD)
     147    pthread_setname_np(threadName);
     148#else
     149    UNUSED_PARAM(threadName);
     150#endif
    142151}
    143152
  • trunk/JavaScriptCore/wtf/ThreadingQt.cpp

    r41156 r41605  
    163163}
    164164
     165void setThreadNameInternal(const char*)
     166{
     167}
     168
    165169int waitForThreadCompletion(ThreadIdentifier threadID, void** result)
    166170{
  • trunk/JavaScriptCore/wtf/ThreadingWin.cpp

    r41156 r41605  
    228228
    229229    return threadID;
     230}
     231
     232void setThreadNameInternal(const char*)
     233{
    230234}
    231235
Note: See TracChangeset for help on using the changeset viewer.