Files
MuditaOS/module-sys/Service/TimerFactory.cpp
Marcin Smoczyński 57874cab33 [BH-912] Improve sys module structure
Improve structure of the module sys. Problems within this module
prevents from linking others.

Signed-off-by: Marcin Smoczyński <smoczynski.marcin@gmail.com>
2021-09-24 10:01:19 +02:00

30 lines
1.2 KiB
C++

// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include <Timers/TimerFactory.hpp>
#include <Timers/SystemTimer.hpp>
namespace sys
{
TimerHandle TimerFactory::createSingleShotTimer(Service *parent,
const std::string &name,
std::chrono::milliseconds interval,
timer::TimerCallback &&callback)
{
auto timer = new timer::SystemTimer(parent, name, interval, timer::Type::SingleShot);
timer->connect(std::move(callback));
return TimerHandle{timer};
}
TimerHandle TimerFactory::createPeriodicTimer(Service *parent,
const std::string &name,
std::chrono::milliseconds interval,
timer::TimerCallback &&callback)
{
auto timer = new timer::SystemTimer(parent, name, interval, timer::Type::Periodic);
timer->connect(std::move(callback));
return TimerHandle{timer};
}
} // namespace sys