| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #ifndef Timer_h | 26 #ifndef Timer_h |
| 27 #define Timer_h | 27 #define Timer_h |
| 28 | 28 |
| 29 #include "platform/PlatformExport.h" | 29 #include "platform/PlatformExport.h" |
| 30 #include "platform/heap/Handle.h" | 30 #include "platform/heap/Handle.h" |
| 31 #include "platform/scheduler/CancellableTaskFactory.h" | |
| 32 #include "public/platform/WebTraceLocation.h" | 31 #include "public/platform/WebTraceLocation.h" |
| 33 #include "wtf/AddressSanitizer.h" | 32 #include "wtf/AddressSanitizer.h" |
| 34 #include "wtf/Noncopyable.h" | 33 #include "wtf/Noncopyable.h" |
| 35 #include "wtf/Threading.h" | 34 #include "wtf/Threading.h" |
| 36 #include "wtf/Vector.h" | 35 #include "wtf/Vector.h" |
| 37 | 36 |
| 38 namespace blink { | 37 namespace blink { |
| 39 | 38 |
| 40 // Time intervals are all in seconds. | 39 // Time intervals are all in seconds. |
| 41 | 40 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 59 void stop(); | 58 void stop(); |
| 60 bool isActive() const; | 59 bool isActive() const; |
| 61 const WebTraceLocation& location() const { return m_location; } | 60 const WebTraceLocation& location() const { return m_location; } |
| 62 | 61 |
| 63 double nextFireInterval() const; | 62 double nextFireInterval() const; |
| 64 double nextUnalignedFireInterval() const; | 63 double nextUnalignedFireInterval() const; |
| 65 NO_LAZY_SWEEP_SANITIZE_ADDRESS | 64 NO_LAZY_SWEEP_SANITIZE_ADDRESS |
| 66 double repeatInterval() const { return m_repeatInterval; } | 65 double repeatInterval() const { return m_repeatInterval; } |
| 67 | 66 |
| 68 void augmentRepeatInterval(double delta) { | 67 void augmentRepeatInterval(double delta) { |
| 69 double now = monotonicallyIncreasingTime(); | 68 setNextFireTime(m_nextFireTime + delta); |
| 70 setNextFireTime(now, m_nextFireTime - now + delta); | |
| 71 m_repeatInterval += delta; | 69 m_repeatInterval += delta; |
| 72 } | 70 } |
| 73 | 71 |
| 74 void didChangeAlignmentInterval(double now); | 72 void didChangeAlignmentInterval(); |
| 75 | 73 |
| 76 private: | 74 private: |
| 77 virtual void fired() = 0; | 75 virtual void fired() = 0; |
| 78 | 76 |
| 79 NO_LAZY_SWEEP_SANITIZE_ADDRESS | 77 NO_LAZY_SWEEP_SANITIZE_ADDRESS |
| 80 virtual double alignedFireTime(double fireTime) const { return fireTime; } | 78 virtual double alignedFireTime(double fireTime) const { return fireTime; } |
| 81 | 79 |
| 82 void setNextFireTime(double now, double delay); | 80 void checkConsistency() const; |
| 81 void checkHeapIndex() const; |
| 83 | 82 |
| 84 void run(); | 83 void setNextFireTime(double); |
| 84 |
| 85 NO_LAZY_SWEEP_SANITIZE_ADDRESS |
| 86 bool inHeap() const { return m_heapIndex != -1; } |
| 87 |
| 88 bool hasValidHeapPosition() const; |
| 89 void updateHeapIfNeeded(double oldTime); |
| 90 |
| 91 void heapDecreaseKey(); |
| 92 void heapDelete(); |
| 93 void heapDeleteMin(); |
| 94 void heapIncreaseKey(); |
| 95 void heapInsert(); |
| 96 void heapPop(); |
| 97 void heapPopMin(); |
| 98 |
| 99 NO_LAZY_SWEEP_SANITIZE_ADDRESS |
| 100 Vector<TimerBase*>& timerHeap() const { ASSERT(m_cachedThreadGlobalTimerHeap
); return *m_cachedThreadGlobalTimerHeap; } |
| 85 | 101 |
| 86 double m_nextFireTime; // 0 if inactive | 102 double m_nextFireTime; // 0 if inactive |
| 87 double m_unalignedNextFireTime; // m_nextFireTime not considering alignment
interval | 103 double m_unalignedNextFireTime; // m_nextFireTime not considering alignment
interval |
| 88 double m_repeatInterval; // 0 if not repeating | 104 double m_repeatInterval; // 0 if not repeating |
| 105 int m_heapIndex; // -1 if not in heap |
| 106 unsigned m_heapInsertionOrder; // Used to keep order among equal-fire-time t
imers |
| 107 Vector<TimerBase*>* m_cachedThreadGlobalTimerHeap; |
| 89 WebTraceLocation m_location; | 108 WebTraceLocation m_location; |
| 90 CancellableTaskFactory m_cancellableTaskFactory; | |
| 91 WebScheduler* m_webScheduler; // Not owned. | |
| 92 | 109 |
| 93 #if ENABLE(ASSERT) | 110 #if ENABLE(ASSERT) |
| 94 ThreadIdentifier m_thread; | 111 ThreadIdentifier m_thread; |
| 95 #endif | 112 #endif |
| 96 | 113 |
| 97 friend class ThreadTimers; | 114 friend class ThreadTimers; |
| 98 friend class TimerHeapLessThanFunction; | 115 friend class TimerHeapLessThanFunction; |
| 99 friend class TimerHeapReference; | 116 friend class TimerHeapReference; |
| 100 }; | 117 }; |
| 101 | 118 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 // in the current code base). | 157 // in the current code base). |
| 141 GC_PLUGIN_IGNORE("363031") | 158 GC_PLUGIN_IGNORE("363031") |
| 142 TimerFiredClass* m_object; | 159 TimerFiredClass* m_object; |
| 143 TimerFiredFunction m_function; | 160 TimerFiredFunction m_function; |
| 144 }; | 161 }; |
| 145 | 162 |
| 146 NO_LAZY_SWEEP_SANITIZE_ADDRESS | 163 NO_LAZY_SWEEP_SANITIZE_ADDRESS |
| 147 inline bool TimerBase::isActive() const | 164 inline bool TimerBase::isActive() const |
| 148 { | 165 { |
| 149 ASSERT(m_thread == currentThread()); | 166 ASSERT(m_thread == currentThread()); |
| 150 return m_cancellableTaskFactory.isPending(); | 167 return m_nextFireTime; |
| 151 } | 168 } |
| 152 | 169 |
| 153 } | 170 } |
| 154 | 171 |
| 155 #endif | 172 #endif |
| OLD | NEW |