diff options
Diffstat (limited to 'WebCore/platform/SharedTimer.h')
-rw-r--r-- | WebCore/platform/SharedTimer.h | 43 |
1 files changed, 36 insertions, 7 deletions
diff --git a/WebCore/platform/SharedTimer.h b/WebCore/platform/SharedTimer.h index 4cc90a2..a005add 100644 --- a/WebCore/platform/SharedTimer.h +++ b/WebCore/platform/SharedTimer.h @@ -28,17 +28,46 @@ namespace WebCore { - // Single timer, shared to implement all the timers managed by the Timer class. + // Each thread has its own single instance of shared timer, which implements this interface. + // This instance is shared by all timers in the thread. // Not intended to be used directly; use the Timer class instead. + class SharedTimer { + public: + virtual ~SharedTimer() {} + virtual void setFiredFunction(void (*)()) = 0; - void setSharedTimerFiredFunction(void (*)()); + // The fire time is relative to the classic POSIX epoch of January 1, 1970, + // as the result of currentTime() is. + virtual void setFireTime(double) = 0; + virtual void stop() = 0; + }; - // The fire time is relative to the classic POSIX epoch of January 1, 1970, - // as the result of currentTime() is. - void setSharedTimerFireTime(double fireTime); + // Implemented by port (since it provides the run loop for the main thread). + // FIXME: make ports implement MainThreadSharedTimer directly instead. + void setSharedTimerFiredFunction(void (*)()); + void setSharedTimerFireTime(double); void stopSharedTimer(); -} + // Implementation of SharedTimer for the main thread. + class MainThreadSharedTimer : public SharedTimer { + public: + virtual void setFiredFunction(void (*function)()) + { + setSharedTimerFiredFunction(function); + } + + virtual void setFireTime(double fireTime) + { + setSharedTimerFireTime(fireTime); + } + + virtual void stop() + { + stopSharedTimer(); + } + }; + +} // namespace WebCore -#endif +#endif // SharedTimer_h |