cpptick - format

This commit is contained in:
erki 2023-10-25 11:36:20 +03:00
parent ddb4931920
commit 0271b0d0de
7 changed files with 43 additions and 48 deletions

View File

@ -4,10 +4,10 @@
#pragma once #pragma once
#include <type_traits>
#include <array> #include <array>
#include <cstring> #include <cstring>
#include <memory> #include <memory>
#include <type_traits>
namespace cpptick namespace cpptick
{ {
@ -115,4 +115,4 @@ struct ArgStorage
} }
}; };
} }// namespace cpptick

View File

@ -5,6 +5,6 @@
#pragma once #pragma once
#include "cpptick/argstore.hpp" #include "cpptick/argstore.hpp"
#include "cpptick/timer.hpp"
#include "cpptick/scheduler.hpp" #include "cpptick/scheduler.hpp"
#include "cpptick/slot.hpp" #include "cpptick/slot.hpp"
#include "cpptick/timer.hpp"

View File

@ -4,9 +4,9 @@
#pragma once #pragma once
#include <tuple>
#include <array>
#include <algorithm> #include <algorithm>
#include <array>
#include <tuple>
#include <utility_function.hpp> #include <utility_function.hpp>
#include <utility_ringbuffer.hpp> #include <utility_ringbuffer.hpp>
@ -120,5 +120,4 @@ struct Scheduler : BaseScheduler
} }
}; };
} }// namespace cpptick

View File

@ -4,9 +4,9 @@
#pragma once #pragma once
#include <memory>
#include <array> #include <array>
#include <cstring> #include <cstring>
#include <memory>
#include <utility_function.hpp> #include <utility_function.hpp>
#include <utility_ringbuffer.hpp> #include <utility_ringbuffer.hpp>
@ -30,8 +30,7 @@ struct Slot<R(Args...)>
Slot() = delete; Slot() = delete;
explicit Slot(BaseScheduler* sched) explicit Slot(BaseScheduler* sched)
: scheduler(sched) : scheduler(sched), invoke_ptr(*this, &Slot<R(Args...)>::callUp)
, invoke_ptr(*this, &Slot<R(Args...)>::callUp)
{ {
signals.fill(nullptr); signals.fill(nullptr);
} }
@ -103,4 +102,4 @@ struct Slot<R(Args...)>
} }
}; };
} }// namespace cpptick

View File

@ -25,9 +25,7 @@ struct Timer
}; };
Timer(BaseScheduler* scheduler, const std::uint32_t timeout_ms, const Type type) Timer(BaseScheduler* scheduler, const std::uint32_t timeout_ms, const Type type)
: scheduler_(scheduler) : scheduler_(scheduler), period_ms(timeout_ms), type(type)
, period_ms(timeout_ms)
, type(type)
{} {}
Timer() = delete; Timer() = delete;
@ -61,9 +59,10 @@ struct Timer
std::uint32_t period_ms; std::uint32_t period_ms;
Type type; Type type;
private: private:
BaseScheduler* scheduler_; BaseScheduler* scheduler_;
Utility::IFunction<void(ArgStorage&)>* slot_ = nullptr; Utility::IFunction<void(ArgStorage&)>* slot_ = nullptr;
}; };
} }// namespace cpptick

View File

@ -14,4 +14,4 @@ void Timer::start()
scheduler_->storeTimer(this); scheduler_->storeTimer(this);
} }
} }// namespace cpptick

View File

@ -36,12 +36,11 @@ struct TestHal
return std::uint32_t( return std::uint32_t(
duration_cast<milliseconds>(system_clock::now().time_since_epoch()) duration_cast<milliseconds>(system_clock::now().time_since_epoch())
.count() .count());
);
} }
}; };
} }// namespace
TEST_CASE("Slot calls function properly with void args.", "[cpptick]") TEST_CASE("Slot calls function properly with void args.", "[cpptick]")
@ -232,8 +231,7 @@ TEST_CASE("Sequential timers operate appropriately.", "[cpptick]")
cpptick::Timer timer_a(&scheduler, 100, cpptick::Timer::PERIODIC); cpptick::Timer timer_a(&scheduler, 100, cpptick::Timer::PERIODIC);
timer_a.setSlot(slot_a); timer_a.setSlot(slot_a);
auto callback_by_two = []() -> void auto callback_by_two = []() -> void {
{
callback_count += 2; callback_count += 2;
}; };
cpptick::Slot<void()> slot_b(&scheduler); cpptick::Slot<void()> slot_b(&scheduler);