diff options
author | Bradley T. Hughes <bradley.hughes@nokia.com> | 2009-06-15 09:57:36 (GMT) |
---|---|---|
committer | Bradley T. Hughes <bradley.hughes@nokia.com> | 2009-06-15 09:57:36 (GMT) |
commit | 336dfcef05cb63df0a6d550b59a4badc7a0f01c1 (patch) | |
tree | a218ec97413e0c8ebc9600ac5db9b2adea485b32 /src/3rdparty/webkit/JavaScriptCore/wtf/Threading.cpp | |
parent | e44d64510e019e5d3b379b704cfb824e0d7ccc9d (diff) | |
download | Qt-336dfcef05cb63df0a6d550b59a4badc7a0f01c1.zip Qt-336dfcef05cb63df0a6d550b59a4badc7a0f01c1.tar.gz Qt-336dfcef05cb63df0a6d550b59a4badc7a0f01c1.tar.bz2 |
Merge of master
Diffstat (limited to 'src/3rdparty/webkit/JavaScriptCore/wtf/Threading.cpp')
-rw-r--r-- | src/3rdparty/webkit/JavaScriptCore/wtf/Threading.cpp | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/src/3rdparty/webkit/JavaScriptCore/wtf/Threading.cpp b/src/3rdparty/webkit/JavaScriptCore/wtf/Threading.cpp index 0179dcc..bd25ee7 100644 --- a/src/3rdparty/webkit/JavaScriptCore/wtf/Threading.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/wtf/Threading.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008 Apple Inc. All rights reserved. + * Copyright (C) 2008, 2009 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -26,16 +26,21 @@ #include "config.h" #include "Threading.h" +#include <string.h> + namespace WTF { struct NewThreadContext { - NewThreadContext(ThreadFunction entryPoint, void* data) + NewThreadContext(ThreadFunction entryPoint, void* data, const char* name) : entryPoint(entryPoint) , data(data) - { } + , name(name) + { + } ThreadFunction entryPoint; void* data; + const char* name; Mutex creationMutex; }; @@ -44,6 +49,8 @@ static void* threadEntryPoint(void* contextData) { NewThreadContext* context = reinterpret_cast<NewThreadContext*>(contextData); + setThreadNameInternal(context->name); + // Block until our creating thread has completed any extra setup work { MutexLocker locker(context->creationMutex); @@ -59,7 +66,14 @@ static void* threadEntryPoint(void* contextData) ThreadIdentifier createThread(ThreadFunction entryPoint, void* data, const char* name) { - NewThreadContext* context = new NewThreadContext(entryPoint, data); + // Visual Studio has a 31-character limit on thread names. Longer names will + // be truncated silently, but we'd like callers to know about the limit. +#if !LOG_DISABLED + if (strlen(name) > 31) + LOG_ERROR("Thread name \"%s\" is longer than 31 characters and will be truncated by Visual Studio", name); +#endif + + NewThreadContext* context = new NewThreadContext(entryPoint, data, name); // Prevent the thread body from executing until we've established the thread identifier MutexLocker locker(context->creationMutex); @@ -72,6 +86,8 @@ ThreadIdentifier createThread(ThreadFunction entryPoint, void* data, const char* // This function is deprecated but needs to be kept around for backward // compatibility. Use the 3-argument version of createThread above. +ThreadIdentifier createThread(ThreadFunction entryPoint, void* data); + ThreadIdentifier createThread(ThreadFunction entryPoint, void* data) { return createThread(entryPoint, data, 0); |