| 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" |
| 31 #include "public/platform/WebTraceLocation.h" | 32 #include "public/platform/WebTraceLocation.h" |
| 32 #include "wtf/AddressSanitizer.h" | 33 #include "wtf/AddressSanitizer.h" |
| 33 #include "wtf/Noncopyable.h" | 34 #include "wtf/Noncopyable.h" |
| 34 #include "wtf/Threading.h" | 35 #include "wtf/Threading.h" |
| 35 #include "wtf/Vector.h" | 36 #include "wtf/Vector.h" |
| 36 | 37 |
| 37 namespace blink { | 38 namespace blink { |
| 38 | 39 |
| 39 // Time intervals are all in seconds. | 40 // Time intervals are all in seconds. |
| 40 | 41 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 58 void stop(); | 59 void stop(); |
| 59 bool isActive() const; | 60 bool isActive() const; |
| 60 const WebTraceLocation& location() const { return m_location; } | 61 const WebTraceLocation& location() const { return m_location; } |
| 61 | 62 |
| 62 double nextFireInterval() const; | 63 double nextFireInterval() const; |
| 63 double nextUnalignedFireInterval() const; | 64 double nextUnalignedFireInterval() const; |
| 64 NO_LAZY_SWEEP_SANITIZE_ADDRESS | 65 NO_LAZY_SWEEP_SANITIZE_ADDRESS |
| 65 double repeatInterval() const { return m_repeatInterval; } | 66 double repeatInterval() const { return m_repeatInterval; } |
| 66 | 67 |
| 67 void augmentRepeatInterval(double delta) { | 68 void augmentRepeatInterval(double delta) { |
| 68 setNextFireTime(m_nextFireTime + delta); | 69 double now = monotonicallyIncreasingTime(); |
| 70 setNextFireTime(now, m_nextFireTime - now + delta); |
| 69 m_repeatInterval += delta; | 71 m_repeatInterval += delta; |
| 70 } | 72 } |
| 71 | 73 |
| 72 void didChangeAlignmentInterval(); | 74 void didChangeAlignmentInterval(double now); |
| 73 | 75 |
| 74 private: | 76 private: |
| 75 virtual void fired() = 0; | 77 virtual void fired() = 0; |
| 76 | 78 |
| 77 NO_LAZY_SWEEP_SANITIZE_ADDRESS | 79 NO_LAZY_SWEEP_SANITIZE_ADDRESS |
| 78 virtual double alignedFireTime(double fireTime) const { return fireTime; } | 80 virtual double alignedFireTime(double fireTime) const { return fireTime; } |
| 79 | 81 |
| 80 void checkConsistency() const; | 82 void setNextFireTime(double now, double delay); |
| 81 void checkHeapIndex() const; | |
| 82 | 83 |
| 83 void setNextFireTime(double); | 84 void run(); |
| 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; } | |
| 101 | 85 |
| 102 double m_nextFireTime; // 0 if inactive | 86 double m_nextFireTime; // 0 if inactive |
| 103 double m_unalignedNextFireTime; // m_nextFireTime not considering alignment
interval | 87 double m_unalignedNextFireTime; // m_nextFireTime not considering alignment
interval |
| 104 double m_repeatInterval; // 0 if not repeating | 88 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; | |
| 108 WebTraceLocation m_location; | 89 WebTraceLocation m_location; |
| 90 CancellableTaskFactory m_cancellableTaskFactory; |
| 91 WebScheduler* m_webScheduler; // Not owned. |
| 109 | 92 |
| 110 #if ENABLE(ASSERT) | 93 #if ENABLE(ASSERT) |
| 111 ThreadIdentifier m_thread; | 94 ThreadIdentifier m_thread; |
| 112 #endif | 95 #endif |
| 113 | 96 |
| 114 friend class ThreadTimers; | 97 friend class ThreadTimers; |
| 115 friend class TimerHeapLessThanFunction; | 98 friend class TimerHeapLessThanFunction; |
| 116 friend class TimerHeapReference; | 99 friend class TimerHeapReference; |
| 117 }; | 100 }; |
| 118 | 101 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 // in the current code base). | 140 // in the current code base). |
| 158 GC_PLUGIN_IGNORE("363031") | 141 GC_PLUGIN_IGNORE("363031") |
| 159 TimerFiredClass* m_object; | 142 TimerFiredClass* m_object; |
| 160 TimerFiredFunction m_function; | 143 TimerFiredFunction m_function; |
| 161 }; | 144 }; |
| 162 | 145 |
| 163 NO_LAZY_SWEEP_SANITIZE_ADDRESS | 146 NO_LAZY_SWEEP_SANITIZE_ADDRESS |
| 164 inline bool TimerBase::isActive() const | 147 inline bool TimerBase::isActive() const |
| 165 { | 148 { |
| 166 ASSERT(m_thread == currentThread()); | 149 ASSERT(m_thread == currentThread()); |
| 167 return m_nextFireTime; | 150 return m_cancellableTaskFactory.isPending(); |
| 168 } | 151 } |
| 169 | 152 |
| 170 } | 153 } |
| 171 | 154 |
| 172 #endif | 155 #endif |
| OLD | NEW |