diff options
Diffstat (limited to 'Source/WTF/wtf/Threading.h')
-rw-r--r-- | Source/WTF/wtf/Threading.h | 66 |
1 files changed, 31 insertions, 35 deletions
diff --git a/Source/WTF/wtf/Threading.h b/Source/WTF/wtf/Threading.h index 31f9d2f34..4cd1593e8 100644 --- a/Source/WTF/wtf/Threading.h +++ b/Source/WTF/wtf/Threading.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007, 2008, 2010 Apple Inc. All rights reserved. + * Copyright (C) 2007, 2008, 2010, 2014 Apple Inc. All rights reserved. * Copyright (C) 2007 Justin Haygood (jhaygood@reaktix.com) * * Redistribution and use in source and binary forms, with or without @@ -11,7 +11,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of + * 3. Neither the name of Apple Inc. ("Apple") nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * @@ -25,42 +25,16 @@ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * - * Note: The implementations of InterlockedIncrement and InterlockedDecrement are based - * on atomic_increment and atomic_exchange_and_add from the Boost C++ Library. The license - * is virtually identical to the Apple license above but is included here for completeness. - * - * Boost Software License - Version 1.0 - August 17th, 2003 - * - * Permission is hereby granted, free of charge, to any person or organization - * obtaining a copy of the software and accompanying documentation covered by - * this license (the "Software") to use, reproduce, display, distribute, - * execute, and transmit the Software, and to prepare derivative works of the - * Software, and to permit third-parties to whom the Software is furnished to - * do so, all subject to the following: - * - * The copyright notices in the Software and this entire statement, including - * the above license grant, this restriction and the following disclaimer, - * must be included in all copies of the Software, in whole or in part, and - * all derivative works of the Software, unless such copies or derivative - * works are solely in the form of machine-executable object code generated by - * a source language processor. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT - * SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE - * FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. */ #ifndef Threading_h #define Threading_h -#include <wtf/Platform.h> +// FIXME: Not sure why there are so many includes here. +// Is this intended to be convenience so that others don't have to include the individual files? +// Nothing in this header depends on Assertions, Atomics, Locker, Noncopyable, ThreadSafeRefCounted, or ThreadingPrimitives. +#include <functional> #include <stdint.h> #include <wtf/Assertions.h> #include <wtf/Atomics.h> @@ -81,6 +55,19 @@ WTF_EXPORT_PRIVATE void initializeThreading(); // Returns 0 if thread creation failed. // The thread name must be a literal since on some platforms it's passed in to the thread. +WTF_EXPORT_PRIVATE ThreadIdentifier createThread(const char* threadName, std::function<void()>); + +// Mark the current thread as requiring UI responsiveness. +// relativePriority is a value in the range [-15, 0] where a lower value indicates a lower priority. +WTF_EXPORT_PRIVATE void setCurrentThreadIsUserInteractive(int relativePriority = 0); +WTF_EXPORT_PRIVATE void setCurrentThreadIsUserInitiated(int relativePriority = 0); + +WTF_EXPORT_PRIVATE ThreadIdentifier currentThread(); +WTF_EXPORT_PRIVATE void changeThreadPriority(ThreadIdentifier, int); +WTF_EXPORT_PRIVATE int waitForThreadCompletion(ThreadIdentifier); +WTF_EXPORT_PRIVATE void detachThread(ThreadIdentifier); + +// Deprecated function-pointer-based thread creation. WTF_EXPORT_PRIVATE ThreadIdentifier createThread(ThreadFunction, void*, const char* threadName); // Internal platform-specific createThread implementation. @@ -90,16 +77,25 @@ ThreadIdentifier createThreadInternal(ThreadFunction, void*, const char* threadN // Helpful for platforms where the thread name must be set from within the thread. void initializeCurrentThreadInternal(const char* threadName); -WTF_EXPORT_PRIVATE ThreadIdentifier currentThread(); -WTF_EXPORT_PRIVATE int waitForThreadCompletion(ThreadIdentifier); -WTF_EXPORT_PRIVATE void detachThread(ThreadIdentifier); +const char* normalizeThreadName(const char* threadName); + +#if HAVE(QOS_CLASSES) +WTF_EXPORT_PRIVATE void setGlobalMaxQOSClass(qos_class_t); +WTF_EXPORT_PRIVATE qos_class_t adjustedQOSClass(qos_class_t); +#endif } // namespace WTF using WTF::ThreadIdentifier; using WTF::createThread; using WTF::currentThread; +using WTF::changeThreadPriority; using WTF::detachThread; using WTF::waitForThreadCompletion; +#if HAVE(QOS_CLASSES) +using WTF::setGlobalMaxQOSClass; +using WTF::adjustedQOSClass; +#endif + #endif // Threading_h |