mirror of
https://github.com/PerMalmberg/libcron.git
synced 2025-04-22 08:23:04 -05:00
Compile on Linux again.
This commit is contained in:
parent
c441da4287
commit
392948cdee
@ -45,7 +45,8 @@ namespace libcron
|
|||||||
return clock;
|
return clock;
|
||||||
}
|
}
|
||||||
|
|
||||||
void get_time_until_expiry_for_tasks(std::vector<std::tuple<std::string, std::chrono::system_clock::duration>>& status) const;
|
void get_time_until_expiry_for_tasks(
|
||||||
|
std::vector<std::tuple<std::string, std::chrono::system_clock::duration>>& status) const;
|
||||||
|
|
||||||
friend std::ostream& operator<<<>(std::ostream& stream, const Cron<ClockType>& c);
|
friend std::ostream& operator<<<>(std::ostream& stream, const Cron<ClockType>& c);
|
||||||
|
|
||||||
@ -93,10 +94,10 @@ namespace libcron
|
|||||||
template<typename ClockType>
|
template<typename ClockType>
|
||||||
std::chrono::system_clock::duration Cron<ClockType>::time_until_next() const
|
std::chrono::system_clock::duration Cron<ClockType>::time_until_next() const
|
||||||
{
|
{
|
||||||
system_clock::duration d{};
|
std::chrono::system_clock::duration d{};
|
||||||
if (tasks.empty())
|
if (tasks.empty())
|
||||||
{
|
{
|
||||||
d = std::numeric_limits<minutes>::max();
|
d = std::numeric_limits<std::chrono::minutes>::max();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -115,7 +116,7 @@ namespace libcron
|
|||||||
{
|
{
|
||||||
first_tick = false;
|
first_tick = false;
|
||||||
}
|
}
|
||||||
else if (now > last_tick && now - last_tick <= hours{3})
|
else if (now > last_tick && now - last_tick <= std::chrono::hours{3})
|
||||||
{
|
{
|
||||||
// Reschedule all tasks.
|
// Reschedule all tasks.
|
||||||
for (auto& t : tasks.get_tasks())
|
for (auto& t : tasks.get_tasks())
|
||||||
@ -123,7 +124,7 @@ namespace libcron
|
|||||||
t.calculate_next(now);
|
t.calculate_next(now);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (now < last_tick && now - last_tick <= -hours{3})
|
else if (now < last_tick && now - last_tick <= -std::chrono::hours{3})
|
||||||
{
|
{
|
||||||
// Reschedule all tasks.
|
// Reschedule all tasks.
|
||||||
for (auto& t : tasks.get_tasks())
|
for (auto& t : tasks.get_tasks())
|
||||||
@ -152,6 +153,7 @@ namespace libcron
|
|||||||
{
|
{
|
||||||
// Must calculate new schedules using second after 'now', otherwise
|
// Must calculate new schedules using second after 'now', otherwise
|
||||||
// we'll run the same task over and over if it takes less than 1s to execute.
|
// we'll run the same task over and over if it takes less than 1s to execute.
|
||||||
|
using namespace std::chrono_literals;
|
||||||
if (task.calculate_next(now + 1s))
|
if (task.calculate_next(now + 1s))
|
||||||
{
|
{
|
||||||
tasks.push(task);
|
tasks.push(task);
|
||||||
@ -162,7 +164,8 @@ namespace libcron
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename ClockType>
|
template<typename ClockType>
|
||||||
void Cron<ClockType>::get_time_until_expiry_for_tasks(std::vector<std::tuple<std::string, std::chrono::system_clock::duration>>& status) const
|
void Cron<ClockType>::get_time_until_expiry_for_tasks(std::vector<std::tuple<std::string,
|
||||||
|
std::chrono::system_clock::duration>>& status) const
|
||||||
{
|
{
|
||||||
auto now = clock.now();
|
auto now = clock.now();
|
||||||
status.clear();
|
status.clear();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user