diff options
Diffstat (limited to 'Source/WTF/wtf/MainThread.h')
-rw-r--r-- | Source/WTF/wtf/MainThread.h | 46 |
1 files changed, 28 insertions, 18 deletions
diff --git a/Source/WTF/wtf/MainThread.h b/Source/WTF/wtf/MainThread.h index f33d71f30..e0a585f36 100644 --- a/Source/WTF/wtf/MainThread.h +++ b/Source/WTF/wtf/MainThread.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007, 2008, 2010 Apple Inc. All rights reserved. + * Copyright (C) 2007, 2008, 2010, 2016 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. * @@ -32,19 +32,23 @@ #include <functional> #include <stdint.h> +#include <wtf/Function.h> +#include <wtf/Optional.h> namespace WTF { +class PrintStream; + typedef uint32_t ThreadIdentifier; -typedef void MainThreadFunction(void*); // Must be called from the main thread. WTF_EXPORT_PRIVATE void initializeMainThread(); -WTF_EXPORT_PRIVATE void callOnMainThread(MainThreadFunction*, void* context); -WTF_EXPORT_PRIVATE void cancelCallOnMainThread(MainThreadFunction*, void* context); +WTF_EXPORT_PRIVATE void callOnMainThread(Function<void ()>&&); -WTF_EXPORT_PRIVATE void callOnMainThread(std::function<void ()>); +#if PLATFORM(COCOA) +WTF_EXPORT_PRIVATE void callOnWebThreadOrDispatchAsyncOnMainThread(void (^block)()); +#endif WTF_EXPORT_PRIVATE void setMainThreadCallbacksPaused(bool paused); @@ -64,23 +68,25 @@ inline bool isWebThread() { return isMainThread(); } inline bool isUIThread() { return isMainThread(); } #endif // USE(WEB_THREAD) -void initializeGCThreads(); +WTF_EXPORT_PRIVATE void initializeGCThreads(); -#if ENABLE(PARALLEL_GC) -void registerGCThread(); -WTF_EXPORT_PRIVATE bool isMainThreadOrGCThread(); -#elif PLATFORM(MAC) || PLATFORM(IOS) +enum class GCThreadType { + Main, + Helper +}; + +void printInternal(PrintStream&, GCThreadType); + +WTF_EXPORT_PRIVATE void registerGCThread(GCThreadType); +WTF_EXPORT_PRIVATE std::optional<GCThreadType> mayBeGCThread(); WTF_EXPORT_PRIVATE bool isMainThreadOrGCThread(); -#else -inline bool isMainThreadOrGCThread() { return isMainThread(); } -#endif // NOTE: these functions are internal to the callOnMainThread implementation. void initializeMainThreadPlatform(); void scheduleDispatchFunctionsOnMainThread(); void dispatchFunctionsFromMainThread(); -#if PLATFORM(MAC) +#if OS(DARWIN) && !PLATFORM(GTK) #if !USE(WEB_THREAD) // This version of initializeMainThread sets up the main thread as corresponding // to the process's main thread, and not necessarily the thread that calls this @@ -92,14 +98,18 @@ void initializeMainThreadToProcessMainThreadPlatform(); } // namespace WTF +using WTF::GCThreadType; using WTF::callOnMainThread; -using WTF::cancelCallOnMainThread; -using WTF::setMainThreadCallbacksPaused; +using WTF::canAccessThreadLocalDataForThread; using WTF::isMainThread; using WTF::isMainThreadOrGCThread; -using WTF::canAccessThreadLocalDataForThread; using WTF::isUIThread; using WTF::isWebThread; +using WTF::mayBeGCThread; +using WTF::setMainThreadCallbacksPaused; +#if PLATFORM(COCOA) +using WTF::callOnWebThreadOrDispatchAsyncOnMainThread; +#endif #if USE(WEB_THREAD) using WTF::initializeWebThread; using WTF::initializeApplicationUIThreadIdentifier; |