Changeset 199694 in webkit
- Timestamp:
- Apr 18, 2016 3:59:31 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 5 added
- 1 deleted
- 12 edited
- 3 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/ChangeLog
r199659 r199694 1 2016-04-18 Yusuke Suzuki <utatane.tea@gmail.com> 2 3 [JSCOnly] Implement RunLoop and remove glib dependency 4 https://bugs.webkit.org/show_bug.cgi?id=155706 5 6 Reviewed by Michael Catanzaro. 7 8 * Source/cmake/OptionsJSCOnly.cmake: 9 1 10 2016-04-18 Carlos Garcia Campos <cgarcia@igalia.com> 2 11 -
trunk/Source/WTF/ChangeLog
r199679 r199694 1 2016-04-18 Yusuke Suzuki <utatane.tea@gmail.com> 2 3 [JSCOnly] Implement RunLoop and remove glib dependency 4 https://bugs.webkit.org/show_bug.cgi?id=155706 5 6 Reviewed by Michael Catanzaro. 7 8 Add missing RunLoop and WorkQueue platform code for JSCOnly port. 9 The implementation does not use platform specific things. Instead, we 10 implement them on WTF framework; using condition variables to construct 11 the run loop and timers. 12 13 Since the fallback is implemented, it is not necessary for JSCOnly port 14 to depend on GLib's RunLoop abstraction. So this patch removes its 15 dependency. As a result, now, JSCOnly port removes dependencies except for the system ICU. 16 17 We clean up event loop ifdefs by introducing USE_XXX_EVENT_LOOP flags. 18 USE(XXX_EVENT_LOOP) is exclusive to each other. So from now, we do not need to take care 19 of the order of if-defs for the event loops. (For example, USE(GLIB) should have lead before 20 OS(DARWIN) in WorkQueue.h for WebKitGTK on Darwin.) 21 22 EVENT_LOOP determination is done in Platform.h. This follows the style of WTF PLATFORM. 23 24 * wtf/Platform.h: 25 * wtf/PlatformJSCOnly.cmake: 26 * wtf/RunLoop.h: 27 * wtf/WorkQueue.h: 28 * wtf/generic/MainThreadGeneric.cpp: Renamed from Source/WTF/wtf/none/MainThreadNone.cpp. 29 (WTF::initializeMainThreadPlatform): 30 (WTF::scheduleDispatchFunctionsOnMainThread): 31 * wtf/generic/RunLoopGeneric.cpp: Added. 32 (WTF::RunLoop::TimerBase::ScheduledTask::create): 33 (WTF::RunLoop::TimerBase::ScheduledTask::ScheduledTask): 34 (WTF::RunLoop::TimerBase::ScheduledTask::fired): 35 (WTF::RunLoop::TimerBase::ScheduledTask::scheduledTimePoint): 36 (WTF::RunLoop::TimerBase::ScheduledTask::updateReadyTime): 37 (WTF::RunLoop::TimerBase::ScheduledTask::EarliestSchedule::operator()): 38 (WTF::RunLoop::TimerBase::ScheduledTask::isActive): 39 (WTF::RunLoop::TimerBase::ScheduledTask::deactivate): 40 (WTF::RunLoop::RunLoop): 41 (WTF::RunLoop::~RunLoop): 42 (WTF::RunLoop::populateTasks): 43 (WTF::RunLoop::runImpl): 44 (WTF::RunLoop::run): 45 (WTF::RunLoop::iterate): 46 (WTF::RunLoop::stop): 47 (WTF::RunLoop::wakeUp): 48 (WTF::RunLoop::schedule): 49 (WTF::RunLoop::scheduleAndWakeUp): 50 (WTF::RunLoop::dispatchAfter): 51 (WTF::RunLoop::TimerBase::TimerBase): 52 (WTF::RunLoop::TimerBase::~TimerBase): 53 (WTF::RunLoop::TimerBase::start): 54 (WTF::RunLoop::TimerBase::stop): 55 (WTF::RunLoop::TimerBase::isActive): 56 * wtf/generic/WorkQueueGeneric.cpp: Added. 57 (WorkQueue::platformInitialize): 58 (WorkQueue::platformInvalidate): 59 (WorkQueue::dispatch): 60 (WorkQueue::dispatchAfter): 61 * wtf/none/MainThreadNone.cpp: 62 (WTF::initializeMainThreadPlatform): Deleted. 63 (WTF::scheduleDispatchFunctionsOnMainThread): Deleted. 64 * wtf/none/RunLoopNone.cpp: 65 (WTF::RunLoop::RunLoop): Deleted. 66 (WTF::RunLoop::~RunLoop): Deleted. 67 (WTF::RunLoop::run): Deleted. 68 (WTF::RunLoop::stop): Deleted. 69 (WTF::RunLoop::wakeUp): Deleted. 70 (WTF::RunLoop::TimerBase::TimerBase): Deleted. 71 (WTF::RunLoop::TimerBase::~TimerBase): Deleted. 72 (WTF::RunLoop::TimerBase::start): Deleted. 73 (WTF::RunLoop::TimerBase::stop): Deleted. 74 (WTF::RunLoop::TimerBase::isActive): Deleted. 75 * wtf/none/WorkQueueNone.cpp: 76 (WorkQueue::platformInitialize): Deleted. 77 (WorkQueue::platformInvalidate): Deleted. 78 (WorkQueue::dispatch): Deleted. 79 (WorkQueue::dispatchAfter): Deleted. 80 1 81 2016-04-18 Commit Queue <commit-queue@webkit.org> 2 82 -
trunk/Source/WTF/wtf/Platform.h
r199366 r199694 1145 1145 #endif 1146 1146 1147 1148 #if !defined(WTF_DEFAULT_EVENT_LOOP) 1149 #define WTF_DEFAULT_EVENT_LOOP 1 1150 #endif 1151 1152 #if WTF_DEFAULT_EVENT_LOOP 1153 #if PLATFORM(WIN) 1154 /* Use Windows message pump abstraction. 1155 * Even if the port is AppleWin, we use the Windows message pump system for the event loop, 1156 * so that USE(WINDOWS_EVENT_LOOP) && USE(CF) can be true. 1157 * And PLATFORM(WIN), PLATFORM(EFL) and PLATFORM(GTK) are exclusive. If the port is GTK, 1158 * PLATFORM(WIN) should be false. And in that case, GLib's event loop is used. 1159 */ 1160 #define USE_WINDOWS_EVENT_LOOP 1 1161 #elif PLATFORM(COCOA) 1162 /* OS X and IOS. Use CoreFoundation & GCD abstraction. */ 1163 #define USE_COCOA_EVENT_LOOP 1 1164 #elif PLATFORM(EFL) 1165 /* EFL port uses GLib. But it uses its own event loop abstraction. 1166 * Thus, USE(EFL_EVENT_LOOP) && USE(GLIB) can be true. 1167 */ 1168 #define USE_EFL_EVENT_LOOP 1 1169 #elif USE(GLIB) 1170 /* Use GLib's event loop abstraction. Primarily GTK port uses it. */ 1171 #define USE_GLIB_EVENT_LOOP 1 1172 #else 1173 #define USE_GENERIC_EVENT_LOOP 1 1174 #endif 1175 #endif 1176 1147 1177 #endif /* WTF_Platform_h */ -
trunk/Source/WTF/wtf/PlatformJSCOnly.cmake
r198086 r199694 1 if (LOWERCASE_EVENT LOOP_TYPE STREQUAL "glib")1 if (LOWERCASE_EVENT_LOOP_TYPE STREQUAL "glib") 2 2 list(APPEND WTF_SOURCES 3 3 glib/GRefPtr.cpp … … 16 16 else () 17 17 list(APPEND WTF_SOURCES 18 none/MainThreadNone.cpp19 none/RunLoopNone.cpp20 none/WorkQueueNone.cpp18 generic/MainThreadGeneric.cpp 19 generic/RunLoopGeneric.cpp 20 generic/WorkQueueGeneric.cpp 21 21 ) 22 22 endif () -
trunk/Source/WTF/wtf/RunLoop.h
r197563 r199694 29 29 #define RunLoop_h 30 30 31 #include <wtf/Condition.h> 31 32 #include <wtf/Deque.h> 32 33 #include <wtf/Forward.h> … … 36 37 #include <wtf/Threading.h> 37 38 38 #if USE(GLIB )39 #if USE(GLIB_EVENT_LOOP) 39 40 #include <wtf/glib/GRefPtr.h> 40 41 #endif 41 42 42 #if PLATFORM(EFL)43 #if USE(EFL_EVENT_LOOP) 43 44 #include <Ecore.h> 44 45 #include <wtf/efl/UniquePtrEfl.h> … … 65 66 WTF_EXPORT_PRIVATE void wakeUp(); 66 67 67 #if PLATFORM(COCOA)68 #if USE(COCOA_EVENT_LOOP) 68 69 WTF_EXPORT_PRIVATE void runForDuration(double duration); 69 70 #endif 70 71 71 #if USE(GLIB ) && !PLATFORM(EFL)72 #if USE(GLIB_EVENT_LOOP) 72 73 WTF_EXPORT_PRIVATE GMainContext* mainContext() const { return m_mainContext.get(); } 74 #endif 75 76 #if USE(GENERIC_EVENT_LOOP) 77 // Run the single iteration of the RunLoop. It consumes the pending tasks and expired timers, but it won't be blocked. 78 WTF_EXPORT_PRIVATE static void iterate(); 79 WTF_EXPORT_PRIVATE void dispatchAfter(std::chrono::nanoseconds, std::function<void()>); 73 80 #endif 74 81 … … 88 95 virtual void fired() = 0; 89 96 90 #if USE(GLIB ) && !PLATFORM(EFL)97 #if USE(GLIB_EVENT_LOOP) 91 98 void setPriority(int); 92 99 #endif … … 97 104 RunLoop& m_runLoop; 98 105 99 #if PLATFORM(WIN)106 #if USE(WINDOWS_EVENT_LOOP) 100 107 static void timerFired(RunLoop*, uint64_t ID); 101 108 uint64_t m_ID; 102 109 bool m_isRepeating; 103 #elif PLATFORM(COCOA)110 #elif USE(COCOA_EVENT_LOOP) 104 111 static void timerFired(CFRunLoopTimerRef, void*); 105 112 RetainPtr<CFRunLoopTimerRef> m_timer; 106 #elif PLATFORM(EFL)113 #elif USE(EFL_EVENT_LOOP) 107 114 static bool timerFired(void* data); 108 115 Ecore_Timer* m_timer; 109 116 bool m_isRepeating; 110 #elif USE(GLIB )117 #elif USE(GLIB_EVENT_LOOP) 111 118 void updateReadyTime(); 112 119 GRefPtr<GSource> m_source; 113 120 bool m_isRepeating { false }; 114 121 std::chrono::microseconds m_fireInterval { 0 }; 122 #elif USE(GENERIC_EVENT_LOOP) 123 class ScheduledTask; 124 RefPtr<ScheduledTask> m_scheduledTask; 115 125 #endif 116 126 }; … … 145 155 Deque<std::function<void ()>> m_functionQueue; 146 156 147 #if PLATFORM(WIN)157 #if USE(WINDOWS_EVENT_LOOP) 148 158 static bool registerRunLoopMessageWindowClass(); 149 159 static LRESULT CALLBACK RunLoopWndProc(HWND, UINT, WPARAM, LPARAM); … … 153 163 typedef HashMap<uint64_t, TimerBase*> TimerMap; 154 164 TimerMap m_activeTimers; 155 #elif PLATFORM(COCOA)165 #elif USE(COCOA_EVENT_LOOP) 156 166 static void performWork(void*); 157 167 RetainPtr<CFRunLoopRef> m_runLoop; 158 168 RetainPtr<CFRunLoopSourceRef> m_runLoopSource; 159 169 int m_nestingLevel; 160 #elif PLATFORM(EFL)170 #elif USE(EFL_EVENT_LOOP) 161 171 Mutex m_pipeLock; 162 172 EflUniquePtr<Ecore_Pipe> m_pipe; … … 166 176 167 177 static void wakeUpEvent(void* data, void*, unsigned); 168 #elif USE(GLIB )178 #elif USE(GLIB_EVENT_LOOP) 169 179 GRefPtr<GMainContext> m_mainContext; 170 180 Vector<GRefPtr<GMainLoop>> m_mainLoops; 171 181 GRefPtr<GSource> m_source; 182 #elif USE(GENERIC_EVENT_LOOP) 183 void schedule(RefPtr<TimerBase::ScheduledTask>&&); 184 void schedule(const LockHolder&, RefPtr<TimerBase::ScheduledTask>&&); 185 void wakeUp(const LockHolder&); 186 void scheduleAndWakeUp(RefPtr<TimerBase::ScheduledTask>); 187 188 enum class RunMode { 189 Iterate, 190 Drain 191 }; 192 193 enum class Status { 194 Clear, 195 Stopping, 196 }; 197 void runImpl(RunMode); 198 bool populateTasks(RunMode, Status&, Deque<RefPtr<TimerBase::ScheduledTask>>&); 199 200 Lock m_loopLock; 201 Condition m_readyToRun; 202 Condition m_stopCondition; 203 Vector<RefPtr<TimerBase::ScheduledTask>> m_schedules; 204 Vector<Status*> m_mainLoops; 205 bool m_shutdown { false }; 206 bool m_pendingTasks { false }; 172 207 #endif 173 208 }; -
trunk/Source/WTF/wtf/WorkQueue.h
r198086 r199694 35 35 #include <wtf/Threading.h> 36 36 37 #if OS(DARWIN) && !PLATFORM(GTK)37 #if USE(COCOA_EVENT_LOOP) 38 38 #include <dispatch/dispatch.h> 39 39 #endif 40 40 41 #if PLATFORM(EFL)41 #if USE(EFL_EVENT_LOOP) 42 42 #include <DispatchQueueEfl.h> 43 #elif USE(GLIB) 44 #include <wtf/Condition.h> 45 #include <wtf/RunLoop.h> 46 #include <wtf/glib/GRefPtr.h> 47 #elif OS(WINDOWS) 43 #endif 44 45 #if USE(WINDOWS_EVENT_LOOP) 48 46 #include <wtf/HashMap.h> 49 47 #include <wtf/Vector.h> 50 48 #include <wtf/win/WorkItemWin.h> 49 #endif 50 51 #if USE(GLIB_EVENT_LOOP) 52 #include <wtf/glib/GRefPtr.h> 53 #endif 54 55 #if USE(GLIB_EVENT_LOOP) || USE(GENERIC_EVENT_LOOP) 56 #include <wtf/Condition.h> 57 #include <wtf/RunLoop.h> 51 58 #endif 52 59 … … 75 82 WTF_EXPORT_PRIVATE static void concurrentApply(size_t iterations, const std::function<void (size_t index)>&); 76 83 77 #if PLATFORM(EFL)84 #if USE(EFL_EVENT_LOOP) 78 85 void registerSocketEventHandler(int, std::function<void ()>); 79 86 void unregisterSocketEventHandler(int); 80 #elif USE(GLIB) 87 #elif USE(COCOA_EVENT_LOOP) 88 dispatch_queue_t dispatchQueue() const { return m_dispatchQueue; } 89 #elif USE(GLIB_EVENT_LOOP) || USE(GENERIC_EVENT_LOOP) 81 90 RunLoop& runLoop() const { return *m_runLoop; } 82 #elif OS(DARWIN)83 dispatch_queue_t dispatchQueue() const { return m_dispatchQueue; }84 91 #endif 85 92 … … 90 97 void platformInvalidate(); 91 98 92 #if OS(WINDOWS)99 #if USE(WINDOWS_EVENT_LOOP) 93 100 static void CALLBACK handleCallback(void* context, BOOLEAN timerOrWaitFired); 94 101 static void CALLBACK timerCallback(void* context, BOOLEAN timerOrWaitFired); … … 103 110 #endif 104 111 105 #if PLATFORM(EFL)112 #if USE(EFL_EVENT_LOOP) 106 113 RefPtr<DispatchQueue> m_dispatchQueue; 107 #elif USE(GLIB) 108 ThreadIdentifier m_workQueueThread; 109 Lock m_initializeRunLoopConditionMutex; 110 Condition m_initializeRunLoopCondition; 111 RunLoop* m_runLoop; 112 Lock m_terminateRunLoopConditionMutex; 113 Condition m_terminateRunLoopCondition; 114 #elif OS(DARWIN) 114 #elif USE(COCOA_EVENT_LOOP) 115 115 static void executeFunction(void*); 116 116 dispatch_queue_t m_dispatchQueue; 117 #elif OS(WINDOWS)117 #elif USE(WINDOWS_EVENT_LOOP) 118 118 volatile LONG m_isWorkThreadRegistered; 119 119 … … 125 125 126 126 HANDLE m_timerQueue; 127 #elif USE(GLIB_EVENT_LOOP) || USE(GENERIC_EVENT_LOOP) 128 ThreadIdentifier m_workQueueThread; 129 Lock m_initializeRunLoopConditionMutex; 130 Condition m_initializeRunLoopCondition; 131 RunLoop* m_runLoop; 132 Lock m_terminateRunLoopConditionMutex; 133 Condition m_terminateRunLoopCondition; 127 134 #endif 128 135 }; -
trunk/Source/WTF/wtf/generic/MainThreadGeneric.cpp
r199693 r199694 1 1 /* 2 2 * Copyright (C) 2016 Konstantin Tokavev <annulen@yandex.ru> 3 * Copyright (C) 2016 Yusuke Suzuki <utatane.tea@gmail.com> 3 4 * 4 5 * Redistribution and use in source and binary forms, with or without … … 27 28 #include "MainThread.h" 28 29 30 #include <wtf/RunLoop.h> 31 29 32 namespace WTF { 30 33 … … 35 38 void scheduleDispatchFunctionsOnMainThread() 36 39 { 40 RunLoop::main().dispatch(std::function<void()>(dispatchFunctionsFromMainThread)); 37 41 } 38 42 -
trunk/Source/cmake/OptionsJSCOnly.cmake
r198388 r199694 12 12 WEBKIT_OPTION_END() 13 13 14 set(ALL_EVENT LOOP_TYPES14 set(ALL_EVENT_LOOP_TYPES 15 15 GLib 16 None16 Generic 17 17 ) 18 18 19 if (UNIX AND NOT APPLE) 20 set(DEFAULT_EVENTLOOP_TYPE "GLib") 21 else () 22 # TODO: Use native Mac and Win implementations 23 set(DEFAULT_EVENTLOOP_TYPE "None") 24 endif () 19 set(DEFAULT_EVENT_LOOP_TYPE "Generic") 25 20 26 set(EVENT LOOP_TYPE ${DEFAULT_EVENTLOOP_TYPE} CACHE STRING "Implementation of event loop to be used in JavaScriptCore (one of ${ALL_EVENTLOOP_TYPES})")21 set(EVENT_LOOP_TYPE ${DEFAULT_EVENT_LOOP_TYPE} CACHE STRING "Implementation of event loop to be used in JavaScriptCore (one of ${ALL_EVENT_LOOP_TYPES})") 27 22 28 23 set(ENABLE_WEBCORE OFF) 29 24 set(ENABLE_WEBKIT OFF) 30 25 set(ENABLE_WEBKIT2 OFF) 31 set(ENABLE_API_TESTS O FF)26 set(ENABLE_API_TESTS ON) 32 27 33 28 if (WTF_CPU_X86 OR WTF_CPU_X86_64) … … 39 34 endif () 40 35 41 string(TOLOWER ${EVENT LOOP_TYPE} LOWERCASE_EVENTLOOP_TYPE)42 if (LOWERCASE_EVENT LOOP_TYPE STREQUAL "glib")36 string(TOLOWER ${EVENT_LOOP_TYPE} LOWERCASE_EVENT_LOOP_TYPE) 37 if (LOWERCASE_EVENT_LOOP_TYPE STREQUAL "glib") 43 38 find_package(GLIB 2.36 REQUIRED COMPONENTS gio gobject) 44 39 SET_AND_EXPOSE_TO_BUILD(USE_GLIB 1) 40 SET_AND_EXPOSE_TO_BUILD(USE_GLIB_EVENT_LOOP 1) 41 SET_AND_EXPOSE_TO_BUILD(WTF_DEFAULT_EVENT_LOOP 0) 42 else () 43 SET_AND_EXPOSE_TO_BUILD(USE_GENERIC_EVENT_LOOP 1) 44 SET_AND_EXPOSE_TO_BUILD(WTF_DEFAULT_EVENT_LOOP 0) 45 45 endif () 46 46 -
trunk/Tools/CMakeLists.txt
r199656 r199694 32 32 add_subdirectory(WebKitTestRunner) 33 33 add_subdirectory(MiniBrowser/mac) 34 elseif ("${PORT}" STREQUAL "JSCOnly") 35 if (ENABLE_API_TESTS) 36 add_subdirectory(TestWebKitAPI) 37 endif () 34 38 endif () 35 39 -
trunk/Tools/ChangeLog
r199681 r199694 1 2016-04-18 Yusuke Suzuki <utatane.tea@gmail.com> 2 3 [JSCOnly] Implement RunLoop and remove glib dependency 4 https://bugs.webkit.org/show_bug.cgi?id=155706 5 6 Reviewed by Michael Catanzaro. 7 8 Add TestWTF to JSCOnly port to test WorkQueue and RunLoop. 9 Platform specific ones locate under jsconly directory since 10 it is not `generic` (Since it includes the GLIB event loop case). 11 12 * CMakeLists.txt: 13 * TestWebKitAPI/PlatformJSCOnly.cmake: Added. 14 * TestWebKitAPI/PlatformUtilities.h: 15 * TestWebKitAPI/Tests/WTF/RunLoop.cpp: 16 (TestWebKitAPI::TEST): 17 * TestWebKitAPI/config.h: 18 * TestWebKitAPI/jsconly/PlatformUtilitiesJSCOnly.cpp: Renamed from Source/WTF/wtf/none/RunLoopNone.cpp. 19 (TestWebKitAPI::Util::run): 20 (TestWebKitAPI::Util::sleep): 21 * TestWebKitAPI/jsconly/main.cpp: Renamed from Source/WTF/wtf/none/WorkQueueNone.cpp. 22 (main): 23 1 24 2016-04-18 Jon Lee <jonlee@apple.com> 2 25 -
trunk/Tools/TestWebKitAPI/PlatformUtilities.h
r188844 r199694 27 27 #define PlatformUtilities_h 28 28 29 #ifndef BUILDING_JSCONLY__ 29 30 #include <WebKit/WKNativeEvent.h> 30 31 #include <WebKit/WKRetainPtr.h> 32 #endif 31 33 #include <string> 32 34 -
trunk/Tools/TestWebKitAPI/Tests/WTF/RunLoop.cpp
r186006 r199694 55 55 } 56 56 57 TEST(WTF_RunLoop, NestedRunLoop) 58 { 59 RunLoop::initializeMainRunLoop(); 60 61 bool testFinished = false; 62 RunLoop::current().dispatch([&] { 63 RunLoop::current().dispatch([&] { 64 testFinished = true; 65 }); 66 Util::run(&testFinished); 67 }); 68 69 Util::run(&testFinished); 70 } 71 72 TEST(WTF_RunLoop, OneShotTimer) 73 { 74 RunLoop::initializeMainRunLoop(); 75 76 bool testFinished = false; 77 78 class DerivedTimer : public RunLoop::Timer<DerivedTimer> { 79 public: 80 DerivedTimer(bool& testFinished) 81 : RunLoop::Timer<DerivedTimer>(RunLoop::current(), this, &DerivedTimer::fired) 82 , m_testFinished(testFinished) 83 { 84 } 85 86 void fired() 87 { 88 m_testFinished = true; 89 stop(); 90 } 91 92 private: 93 bool& m_testFinished; 94 }; 95 96 { 97 DerivedTimer timer(testFinished); 98 timer.startOneShot(0.1); 99 Util::run(&testFinished); 100 } 101 } 102 103 TEST(WTF_RunLoop, RepeatingTimer) 104 { 105 RunLoop::initializeMainRunLoop(); 106 107 bool testFinished = false; 108 109 class DerivedTimer : public RunLoop::Timer<DerivedTimer> { 110 public: 111 DerivedTimer(bool& testFinished) 112 : RunLoop::Timer<DerivedTimer>(RunLoop::current(), this, &DerivedTimer::fired) 113 , m_testFinished(testFinished) 114 { 115 } 116 117 void fired() 118 { 119 if (++m_count == 10) { 120 m_testFinished = true; 121 stop(); 122 } 123 } 124 125 private: 126 unsigned m_count { 0 }; 127 bool& m_testFinished; 128 }; 129 130 { 131 DerivedTimer timer(testFinished); 132 timer.startRepeating(0.01); 133 Util::run(&testFinished); 134 } 135 } 136 137 TEST(WTF_RunLoop, ManyTimes) 138 { 139 RunLoop::initializeMainRunLoop(); 140 141 class Counter { 142 public: 143 void run() 144 { 145 if (++m_count == 100000) { 146 RunLoop::current().stop(); 147 return; 148 } 149 RunLoop::current().dispatch([this] { 150 run(); 151 }); 152 } 153 154 private: 155 unsigned m_count { 0 }; 156 }; 157 158 Counter counter; 159 160 RunLoop::current().dispatch([&counter] { 161 counter.run(); 162 }); 163 RunLoop::run(); 164 } 165 57 166 } // namespace TestWebKitAPI -
trunk/Tools/TestWebKitAPI/config.h
r188643 r199694 28 28 #endif 29 29 30 #include <runtime/JSExportMacros.h> 31 #ifndef BUILDING_JSCONLY__ 30 32 #include <WebCore/PlatformExportMacros.h> 31 # include <runtime/JSExportMacros.h>33 #endif 32 34 33 35 #if defined(__APPLE__) && __APPLE__ … … 64 66 #include <stdint.h> 65 67 66 #if !PLATFORM(IOS) && !PLATFORM(WIN) && !(PLATFORM(GTK) && !defined(BUILDING_WEBKIT2__)) 68 #if !PLATFORM(IOS) && !PLATFORM(WIN) && !(PLATFORM(GTK) && !defined(BUILDING_WEBKIT2__)) && !defined(BUILDING_JSCONLY__) 67 69 #include <WebKit/WebKit2_C.h> 68 70 #endif … … 90 92 #endif 91 93 92 #if !PLATFORM(IOS) 94 #if !PLATFORM(IOS) && !defined(BUILDING_JSCONLY__) 93 95 #define WK_HAVE_C_SPI 1 94 96 #endif -
trunk/Tools/TestWebKitAPI/jsconly/PlatformUtilitiesJSCOnly.cpp
r199693 r199694 1 1 /* 2 * Copyright (C) 2016 Konstantin Tokavev <annulen@yandex.ru>2 * Copyright (C) 2016 Yusuke Suzuki <utatane.tea@gmail.com> 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 25 25 26 26 #include "config.h" 27 #include " RunLoop.h"27 #include "PlatformUtilities.h" 28 28 29 namespace WTF { 29 #include <wtf/CurrentTime.h> 30 #include <wtf/RunLoop.h> 30 31 31 RunLoop::RunLoop() 32 #if USE(GLIB_EVENT_LOOP) 33 #include <glib.h> 34 #include <wtf/glib/GRefPtr.h> 35 #endif 36 37 namespace TestWebKitAPI { 38 namespace Util { 39 40 void run(bool* done) 32 41 { 42 while (!*done) { 43 #if USE(GLIB_EVENT_LOOP) 44 g_main_context_iteration(RunLoop::current().mainContext(), false); 45 #else 46 WTF::RunLoop::iterate(); 47 #endif 48 } 33 49 } 34 50 35 RunLoop::~RunLoop()51 void sleep(double seconds) 36 52 { 53 WTF::sleep(seconds); 37 54 } 38 55 39 void RunLoop::run() 40 { 41 } 42 43 void RunLoop::stop() 44 { 45 } 46 47 void RunLoop::wakeUp() 48 { 49 ASSERT_NOT_REACHED(); 50 } 51 52 RunLoop::TimerBase::TimerBase(RunLoop& runLoop) 53 : m_runLoop(runLoop) 54 { 55 } 56 57 RunLoop::TimerBase::~TimerBase() 58 { 59 stop(); 60 } 61 62 void RunLoop::TimerBase::start(double, bool) 63 { 64 } 65 66 void RunLoop::TimerBase::stop() 67 { 68 } 69 70 bool RunLoop::TimerBase::isActive() const 71 { 72 return false; 73 } 74 75 } // namespace WTF 56 } // namespace Util 57 } // namespace TestWebKitAPI -
trunk/Tools/TestWebKitAPI/jsconly/main.cpp
r199693 r199694 1 1 /* 2 * Copyright (C) 2016 Konstantin Tokavev <annulen@yandex.ru>2 * Copyright (C) 2016 Yusuke Suzuki <utatane.tea@gmail.com> 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 25 25 26 26 #include "config.h" 27 #include " WorkQueue.h"27 #include "TestsController.h" 28 28 29 void WorkQueue::platformInitialize(const char*, Type, QOS)29 int main(int argc, char** argv) 30 30 { 31 return TestWebKitAPI::TestsController::singleton().run(argc, argv) ? EXIT_SUCCESS : EXIT_FAILURE; 31 32 } 32 33 void WorkQueue::platformInvalidate()34 {35 }36 37 void WorkQueue::dispatch(std::function<void()>)38 {39 ASSERT_NOT_REACHED();40 }41 42 void WorkQueue::dispatchAfter(std::chrono::nanoseconds, std::function<void()>)43 {44 ASSERT_NOT_REACHED();45 }
Note: See TracChangeset
for help on using the changeset viewer.