summaryrefslogtreecommitdiff
path: root/Source/WebCore/platform/SharedTimer.h
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/platform/SharedTimer.h')
-rw-r--r--Source/WebCore/platform/SharedTimer.h64
1 files changed, 21 insertions, 43 deletions
diff --git a/Source/WebCore/platform/SharedTimer.h b/Source/WebCore/platform/SharedTimer.h
index 561091197..7777f67c9 100644
--- a/Source/WebCore/platform/SharedTimer.h
+++ b/Source/WebCore/platform/SharedTimer.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
+ * Copyright (C) 2006-2016 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -10,10 +10,10 @@
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
@@ -26,51 +26,29 @@
#ifndef SharedTimer_h
#define SharedTimer_h
+#include <functional>
#include <wtf/FastMalloc.h>
#include <wtf/Noncopyable.h>
+#include <wtf/Seconds.h>
namespace WebCore {
- // 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 {
- WTF_MAKE_NONCOPYABLE(SharedTimer); WTF_MAKE_FAST_ALLOCATED;
- public:
- SharedTimer() { }
- virtual ~SharedTimer() {}
- virtual void setFiredFunction(void (*)()) = 0;
-
- // The fire interval is in seconds relative to the current monotonic clock time.
- virtual void setFireInterval(double) = 0;
- virtual void stop() = 0;
- };
-
-
- // Implemented by port (since it provides the run loop for the main thread).
- // FIXME: make ports implement MainThreadSharedTimer directly instead.
- void setSharedTimerFiredFunction(void (*)());
- void setSharedTimerFireInterval(double);
- void stopSharedTimer();
-
- // Implementation of SharedTimer for the main thread.
- class MainThreadSharedTimer : public SharedTimer {
- public:
- virtual void setFiredFunction(void (*function)())
- {
- setSharedTimerFiredFunction(function);
- }
-
- virtual void setFireInterval(double interval)
- {
- setSharedTimerFireInterval(interval);
- }
-
- virtual void stop()
- {
- stopSharedTimer();
- }
- };
+// 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 {
+ WTF_MAKE_NONCOPYABLE(SharedTimer); WTF_MAKE_FAST_ALLOCATED;
+public:
+ SharedTimer() = default;
+ virtual ~SharedTimer() { }
+ virtual void setFiredFunction(std::function<void()>&&) = 0;
+
+ // The fire interval is in seconds relative to the current monotonic clock time.
+ virtual void setFireInterval(Seconds) = 0;
+ virtual void stop() = 0;
+
+ virtual void invalidate() { }
+};
} // namespace WebCore