PrevUpHomeNext

Introduction

Recurring actions

Tasks are often planned and performed repeatedly, very often recurring in regular intervals. This includes annual events on calendar dates.

Hence what we need is an iterator that is able to iterate over time and date. The Boost Date/Time library is a very powerful library for this. In fact, synkronize utilises the Boost Date/Time library.

The problem is that time/date iterators relate to scheduling like C++ iterators to their respective container/range.

A programmer usually cares less about the iteration process and the necessary iterator - rather the wish is to express when and how often to schedule an action. Ultimately, one needs the timepoints yielded by the iteration process.

It's all about simplicity and semantically meaningful usage.

Simplicity

Obviously things are getting quickly more complicated if you wanted to deal with multiple calendar dates and certain actions to be triggered - consider e.g. a U.S. Federal Holiday schedule that should suspend a program during these known days of observance.

This is where the huge benefit of synkronize providing a timepoint generator comes into play. It's a timepiece device that you simply configure how you want it to generate timepoints, and off you go getting sequential timepoints. That's also the reason why the library focuses on the concept of 'scheduling' rather than timepoint iteration.

The synkronize library offers a rich set of features for date/time scheduling.

Yet, there are basically only 4 things to do:

// 1) prepare schedule definition
fd::interval_schedule_data sd{ fd::day_interval };

// 2) create and initialize timepoint generator from schedule definition
fd::schedule_timepiece scheduler{ sd };

// 3) extract generated timepoint as unix timestamp
std::chrono::seconds next = currently_scheduled_at__s(scheduler);

// 4a) advance to next timepoint and extract generated timepoint
next = advance__s(scheduler, fd::timepiece_move::to_adjacent)

// 4b) work with the generated timepoint
next = currently_scheduled_at__s(scheduler);

Features


PrevUpHomeNext