| 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 | 115 |
| 116 template <typename TimerFiredClass> | 116 template <typename TimerFiredClass> |
| 117 class Timer final : public TimerBase { | 117 class Timer final : public TimerBase { |
| 118 public: | 118 public: |
| 119 typedef void (TimerFiredClass::*TimerFiredFunction)(Timer*); | 119 typedef void (TimerFiredClass::*TimerFiredFunction)(Timer*); |
| 120 | 120 |
| 121 Timer(TimerFiredClass* o, TimerFiredFunction f) | 121 Timer(TimerFiredClass* o, TimerFiredFunction f) |
| 122 : m_object(o), m_function(f) { } | 122 : m_object(o), m_function(f) { } |
| 123 | 123 |
| 124 private: | 124 private: |
| 125 virtual void fired() override { (m_object->*m_function)(this); } | 125 virtual void fired() override |
| 126 { |
| 127 // Oilpan: if a timer fires while Oilpan heaps are being lazily |
| 128 // swept, it is not safe to proceed if the object is dead. |
| 129 // Assume this timer will be stopped once the object is finalized. |
| 130 if (IsGarbageCollectedType<TimerFiredClass>::value && !Heap::isObjectAli
ve(m_object)) |
| 131 return; |
| 132 |
| 133 (m_object->*m_function)(this); |
| 134 } |
| 126 | 135 |
| 127 // FIXME: oilpan: TimerBase should be moved to the heap and m_object should
be traced. | 136 // FIXME: oilpan: TimerBase should be moved to the heap and m_object should
be traced. |
| 128 // This raw pointer is safe as long as Timer<X> is held by the X itself (Tha
t's the case | 137 // This raw pointer is safe as long as Timer<X> is held by the X itself (Tha
t's the case |
| 129 // in the current code base). | 138 // in the current code base). |
| 130 GC_PLUGIN_IGNORE("363031") | 139 GC_PLUGIN_IGNORE("363031") |
| 131 TimerFiredClass* m_object; | 140 TimerFiredClass* m_object; |
| 132 TimerFiredFunction m_function; | 141 TimerFiredFunction m_function; |
| 133 }; | 142 }; |
| 134 | 143 |
| 135 inline bool TimerBase::isActive() const | 144 inline bool TimerBase::isActive() const |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 TimerFiredClass* m_object; | 196 TimerFiredClass* m_object; |
| 188 TimerFiredFunction m_function; | 197 TimerFiredFunction m_function; |
| 189 | 198 |
| 190 double m_delay; | 199 double m_delay; |
| 191 bool m_shouldRestartWhenTimerFires; | 200 bool m_shouldRestartWhenTimerFires; |
| 192 }; | 201 }; |
| 193 | 202 |
| 194 } | 203 } |
| 195 | 204 |
| 196 #endif | 205 #endif |
| OLD | NEW |