Changeset 214732 in webkit
- Timestamp:
- Apr 2, 2017 10:41:30 PM (7 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r214714 r214732 1 2017-04-02 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 Share implementation of JSRunLoopTimer::timerDidFire 4 https://bugs.webkit.org/show_bug.cgi?id=170392 5 6 Reviewed by Michael Catanzaro. 7 8 The code is cross-platform but it's duplicated in CF and GLib implementations, it could be shared instead. 9 10 * runtime/JSRunLoopTimer.cpp: 11 (JSC::JSRunLoopTimer::timerDidFire): Move common implementation here. 12 (JSC::JSRunLoopTimer::setRunLoop): Use timerDidFireCallback. 13 (JSC::JSRunLoopTimer::timerDidFireCallback): Call JSRunLoopTimer::timerDidFire(). 14 * runtime/JSRunLoopTimer.h: 15 1 16 2017-04-01 Oleksandr Skachkov <gskachkov@gmail.com> 2 17 -
trunk/Source/JavaScriptCore/runtime/JSRunLoopTimer.cpp
r214504 r214732 42 42 namespace JSC { 43 43 44 void JSRunLoopTimer::timerDidFire() 45 { 46 m_apiLock->lock(); 47 48 RefPtr<VM> vm = m_apiLock->vm(); 49 if (!vm) { 50 // The VM has been destroyed, so we should just give up. 51 m_apiLock->unlock(); 52 return; 53 } 54 55 { 56 JSLockHolder locker(vm.get()); 57 doWork(); 58 } 59 60 m_apiLock->unlock(); 61 } 62 44 63 #if USE(CF) 45 64 … … 66 85 memset(&m_context, 0, sizeof(CFRunLoopTimerContext)); 67 86 m_context.info = this; 68 m_timer = adoptCF(CFRunLoopTimerCreate(kCFAllocatorDefault, CFAbsoluteTimeGetCurrent() + s_decade, s_decade, 0, 0, JSRunLoopTimer::timerDidFire , &m_context));87 m_timer = adoptCF(CFRunLoopTimerCreate(kCFAllocatorDefault, CFAbsoluteTimeGetCurrent() + s_decade, s_decade, 0, 0, JSRunLoopTimer::timerDidFireCallback, &m_context)); 69 88 CFRunLoopAddTimer(m_runLoop.get(), m_timer.get(), kCFRunLoopCommonModes); 70 89 } … … 76 95 } 77 96 78 void JSRunLoopTimer::timerDidFire (CFRunLoopTimerRef, void* contextPtr)97 void JSRunLoopTimer::timerDidFireCallback(CFRunLoopTimerRef, void* contextPtr) 79 98 { 80 JSRunLoopTimer* timer = static_cast<JSRunLoopTimer*>(contextPtr); 81 timer->m_apiLock->lock(); 82 83 RefPtr<VM> vm = timer->m_apiLock->vm(); 84 if (!vm) { 85 // The VM has been destroyed, so we should just give up. 86 timer->m_apiLock->unlock(); 87 return; 88 } 89 90 { 91 JSLockHolder locker(vm.get()); 92 timer->doWork(); 93 } 94 95 timer->m_apiLock->unlock(); 99 static_cast<JSRunLoopTimer*>(contextPtr)->timerDidFire(); 96 100 } 97 101 … … 145 149 } 146 150 147 void JSRunLoopTimer::timerDidFire()148 {149 m_apiLock->lock();150 151 if (!m_apiLock->vm()) {152 // The VM has been destroyed, so we should just give up.153 m_apiLock->unlock();154 return;155 }156 157 {158 JSLockHolder locker(m_vm);159 doWork();160 }161 162 m_apiLock->unlock();163 }164 165 151 void JSRunLoopTimer::scheduleTimer(double intervalInSeconds) 166 152 { … … 184 170 } 185 171 186 void JSRunLoopTimer::invalidate()187 {188 }189 190 172 void JSRunLoopTimer::scheduleTimer(double) 191 173 { -
trunk/Source/JavaScriptCore/runtime/JSRunLoopTimer.h
r214504 r214732 49 49 JSRunLoopTimer(VM*); 50 50 #if USE(CF) 51 static void timerDidFire (CFRunLoopTimerRef, void*);51 static void timerDidFireCallback(CFRunLoopTimerRef, void*); 52 52 #endif 53 53 … … 79 79 #elif USE(GLIB) 80 80 static const long s_decade; 81 void timerDidFire();82 81 GRefPtr<GSource> m_timer; 83 82 #endif 84 83 85 84 private: 86 void invalidate();85 void timerDidFire(); 87 86 }; 88 87
Note: See TracChangeset
for help on using the changeset viewer.