Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: include/AdblockPlus/ITimer.h

Issue 29395640: Issue 3595 - Get rid of detached threads for setTimeout (Closed)
Patch Set: Created March 27, 2017, 10:26 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | include/AdblockPlus/JsEngine.h » ('j') | src/DefaultTimer.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/AdblockPlus/ITimer.h
diff --git a/include/AdblockPlus/LogSystem.h b/include/AdblockPlus/ITimer.h
similarity index 52%
copy from include/AdblockPlus/LogSystem.h
copy to include/AdblockPlus/ITimer.h
index 6a71d5cfa98daf9390825e913143bf9f5b54f436..291e56f1626418daa7dacd9ddfd0a53611137fe5 100644
--- a/include/AdblockPlus/LogSystem.h
+++ b/include/AdblockPlus/ITimer.h
@@ -15,42 +15,38 @@
* along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef ADBLOCK_PLUS_LOG_SYSTEM_H
-#define ADBLOCK_PLUS_LOG_SYSTEM_H
+#ifndef ADBLOCK_PLUS_TIMER_H
+#define ADBLOCK_PLUS_TIMER_H
-#include <string>
+#include <functional>
+#include <chrono>
#include <memory>
namespace AdblockPlus
{
/**
- * Logging interface.
+ * Timer manager interface.
*/
- class LogSystem
+ struct ITimer
{
- public:
/**
- * Log level.
- */
- enum LogLevel {LOG_LEVEL_TRACE, LOG_LEVEL_LOG, LOG_LEVEL_INFO, LOG_LEVEL_WARN, LOG_LEVEL_ERROR};
-
- virtual ~LogSystem() {}
+ * Callback type invoked after elapsing of timer timeout.
+ */
+ typedef std::function<void()> TimerCallback;
+ virtual ~ITimer() {};
/**
- * Writes a log message.
- * @param logLevel Log level.
- * @param message Log message.
- * @param source Source of the message, e.g. file name and line.
- * Ignored when empty.
+ * Sets a timer.
+ * @param timeout A timer callback will be called after that interval.
+ * @param timeCallback The callback which is called after timeout.
*/
- virtual void operator()(LogLevel logLevel, const std::string& message,
- const std::string& source) = 0;
+ virtual void SetTimer(const std::chrono::milliseconds& timeout, const TimerCallback& timerCallback) = 0;
};
/**
- * Shared smart pointer to a `LogSystem` instance.
+ * Unique smart pointer to an instance of `ITimer` implementation.
*/
- typedef std::shared_ptr<LogSystem> LogSystemPtr;
+ typedef std::unique_ptr<ITimer> TimerPtr;
}
#endif
« no previous file with comments | « no previous file | include/AdblockPlus/JsEngine.h » ('j') | src/DefaultTimer.h » ('J')

Powered by Google App Engine
This is Rietveld