add .clang-format
Change-Id: I94ce26d595367e08d6fb3734535bcd855f1b1473
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/timer.cpp b/timer.cpp
index 973b012..a99ec46 100644
--- a/timer.cpp
+++ b/timer.cpp
@@ -1,7 +1,9 @@
+#include "timer.hpp"
+
+#include <string.h>
+
#include <chrono>
#include <system_error>
-#include <string.h>
-#include "timer.hpp"
namespace phosphor
{
@@ -15,36 +17,32 @@
return duration_cast<microseconds>(usec);
}
-Timer::Timer(sd_event* event,
- std::function<void()> callback,
- std::chrono::microseconds usec,
- timer::Action action):
+Timer::Timer(sd_event* event, std::function<void()> callback,
+ std::chrono::microseconds usec, timer::Action action) :
event(event),
- callback(callback),
- duration(usec),
- action(action)
+ callback(callback), duration(usec), action(action)
{
auto r = sd_event_add_time(event, &eventSource,
- CLOCK_MONOTONIC, // Time base
+ CLOCK_MONOTONIC, // Time base
(getTime() + usec).count(), // When to fire
- 0, // Use default event accuracy
+ 0, // Use default event accuracy
timeoutHandler, // Callback handler on timeout
- this); // User data
+ this); // User data
if (r < 0)
{
throw std::system_error(r, std::generic_category(), strerror(-r));
}
}
-int Timer::timeoutHandler(sd_event_source* eventSource,
- uint64_t usec, void* userData)
+int Timer::timeoutHandler(sd_event_source* eventSource, uint64_t usec,
+ void* userData)
{
auto timer = static_cast<Timer*>(userData);
if (timer->getAction() == timer::ON)
{
auto r = sd_event_source_set_time(
- eventSource, (getTime() + timer->getDuration()).count());
+ eventSource, (getTime() + timer->getDuration()).count());
if (r < 0)
{
throw std::system_error(r, std::generic_category(), strerror(-r));
@@ -56,7 +54,7 @@
}
}
- if(timer->callback)
+ if (timer->callback)
{
timer->callback();
}