RESOLVED FIXED 87824
Factor DeferrableOneShotTimer out of GraphicsContextCG/GeneratorGeneratedImage
https://bugs.webkit.org/show_bug.cgi?id=87824
Summary Factor DeferrableOneShotTimer out of GraphicsContextCG/GeneratorGeneratedImage
Tim Horton
Reported 2012-05-29 22:54:34 PDT
I copied and pasted some code from GraphicsContextCG into GeneratorGeneratedImage, and I shouldn't have. We should move this code to somewhere more generic so that it can be reused, especially as it's particularly useful for clearing caches! DeferrableOneShotTimer is a timer which takes a class+method to call (as Timer does), and a delay. It exposes restart(), stop(), and isActive(), and none of the rest of the TimerBase interface. On restart(), the timer is started with the given delay, unless it's already running, in which case a flag is set to automatically restart the timer when it fires instead of calling the given method. This provides a low-overhead way to implement a deferrable timer. This will be used to clear GraphicsContextCG's subimage cache and GeneratorGeneratedImage's generated image cache. I have a patch. I'm also open to better names and/or moving it into its own header if needed.
Attachments
patch (8.03 KB, patch)
2012-05-29 23:31 PDT, Tim Horton
simon.fraser: review+
Tim Horton
Comment 1 2012-05-29 23:31:55 PDT
Simon Fraser (smfr)
Comment 2 2012-05-30 09:02:33 PDT
Comment on attachment 144724 [details] patch View in context: https://bugs.webkit.org/attachment.cgi?id=144724&action=review Nice. > Source/WebCore/platform/Timer.h:127 > + // again, which might result in rescheduling the system timer and that s/and that/which > Source/WebCore/platform/Timer.h:155 > + bool m_shouldRestartWhenTimerFires; > + double m_delay; Putting the bool last might get you better packing and a smaller object.
Tim Horton
Comment 3 2012-05-30 11:28:53 PDT
Darin Adler
Comment 4 2012-05-30 12:48:46 PDT
Comment on attachment 144724 [details] patch View in context: https://bugs.webkit.org/attachment.cgi?id=144724&action=review >> Source/WebCore/platform/Timer.h:127 >> + // again, which might result in rescheduling the system timer and that > > s/and that/which I don’t agree. That goes against my elementary school training about the use of which vs. that.
Note You need to log in before you can comment on or make changes to this bug.