mirror of
https://github.com/PerMalmberg/libcron.git
synced 2025-06-07 12:32:10 -05:00
Added code to ensure that code snippets in Readme compile. (#46)
* Update README.md Added missing stream insertion operator to example. Also, header files for chrono and thread as well as a missing namespace for literals added. --------- Co-authored-by: Per Malmberg <PerMalmberg@users.noreply.github.com>
This commit is contained in:
parent
aa3d4368d5
commit
de143e8b8e
10
README.md
10
README.md
@ -6,10 +6,16 @@ A C++ scheduling library using cron formatting.
|
|||||||
Libcron offers an easy to use API to add callbacks with corresponding cron-formatted strings:
|
Libcron offers an easy to use API to add callbacks with corresponding cron-formatted strings:
|
||||||
|
|
||||||
```
|
```
|
||||||
|
#include <libcron/Cron.h>
|
||||||
|
#include <libcron/CronData.h>
|
||||||
|
#include <chrono>
|
||||||
|
#include <thread>
|
||||||
|
using namespace std::chrono_literals;
|
||||||
|
|
||||||
libcron::Cron cron;
|
libcron::Cron cron;
|
||||||
|
|
||||||
cron.add_schedule("Hello from Cron", "* * * * * ?", [=](auto&) {
|
cron.add_schedule("Hello from Cron", "* * * * * ?", [=](auto&) {
|
||||||
std::cout << "Hello from libcron!" std::endl;
|
std::cout << "Hello from libcron!" << std::endl;
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -19,7 +25,7 @@ To trigger the execution of callbacks, one must call `libcron::Cron::tick` at le
|
|||||||
while(true)
|
while(true)
|
||||||
{
|
{
|
||||||
cron.tick();
|
cron.tick();
|
||||||
std::this_thread::sleep_for(500mS);
|
std::this_thread::sleep_for(500ms);
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user