diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-06-20 13:01:08 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-06-20 13:01:08 +0200 |
commit | 49233e234e5c787396cadb2cea33b31ae0cd65c1 (patch) | |
tree | 5410cb9a8fd53168bb60d62c54b654d86f03c38d /Source/JavaScriptCore/heap/HeapTimer.cpp | |
parent | b211c645d8ab690f713515dfdc84d80b11c27d2c (diff) | |
download | qtwebkit-49233e234e5c787396cadb2cea33b31ae0cd65c1.tar.gz |
Imported WebKit commit 3a8c29f35d00659d2ce7a0ccdfa8304f14e82327 (http://svn.webkit.org/repository/webkit/trunk@120813)
New snapshot with Windows build fixes
Diffstat (limited to 'Source/JavaScriptCore/heap/HeapTimer.cpp')
-rw-r--r-- | Source/JavaScriptCore/heap/HeapTimer.cpp | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/Source/JavaScriptCore/heap/HeapTimer.cpp b/Source/JavaScriptCore/heap/HeapTimer.cpp new file mode 100644 index 000000000..bc42032f5 --- /dev/null +++ b/Source/JavaScriptCore/heap/HeapTimer.cpp @@ -0,0 +1,71 @@ +#include "config.h" +#include "HeapTimer.h" + +#include <wtf/Threading.h> + +namespace JSC { + +#if USE(CF) + +const CFTimeInterval HeapTimer::s_decade = 60 * 60 * 24 * 365 * 10; + +HeapTimer::HeapTimer(JSGlobalData* globalData, CFRunLoopRef runLoop) + : m_globalData(globalData) + , m_runLoop(runLoop) +{ + memset(&m_context, 0, sizeof(CFRunLoopTimerContext)); + m_context.info = this; + m_timer.adoptCF(CFRunLoopTimerCreate(0, s_decade, s_decade, 0, 0, HeapTimer::timerDidFire, &m_context)); + CFRunLoopAddTimer(m_runLoop.get(), m_timer.get(), kCFRunLoopCommonModes); +} + +HeapTimer::~HeapTimer() +{ + invalidate(); +} + +void HeapTimer::synchronize() +{ + if (CFRunLoopGetCurrent() == m_runLoop.get()) + return; + CFRunLoopRemoveTimer(m_runLoop.get(), m_timer.get(), kCFRunLoopCommonModes); + m_runLoop = CFRunLoopGetCurrent(); + CFRunLoopAddTimer(m_runLoop.get(), m_timer.get(), kCFRunLoopCommonModes); +} + +void HeapTimer::invalidate() +{ + CFRunLoopRemoveTimer(m_runLoop.get(), m_timer.get(), kCFRunLoopCommonModes); + CFRunLoopTimerInvalidate(m_timer.get()); +} + +void HeapTimer::timerDidFire(CFRunLoopTimerRef, void* info) +{ + HeapTimer* agent = static_cast<HeapTimer*>(info); + agent->doWork(); +} + +#else + +HeapTimer::HeapTimer(JSGlobalData* globalData) + : m_globalData(globalData) +{ +} + +HeapTimer::~HeapTimer() +{ +} + +void HeapTimer::synchronize() +{ +} + +void HeapTimer::invalidate() +{ +} + + +#endif + + +} // namespace JSC |