Changeset 214732 in webkit for trunk/Source/JavaScriptCore/runtime/JSRunLoopTimer.cpp
- Timestamp:
- Apr 2, 2017, 10:41:30 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 {
Note:
See TracChangeset
for help on using the changeset viewer.