Skip to content

Commit de143e8

Browse files
nkinarPerMalmberg
andauthored
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>
1 parent aa3d436 commit de143e8

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,16 @@ A C++ scheduling library using cron formatting.
66
Libcron offers an easy to use API to add callbacks with corresponding cron-formatted strings:
77

88
```
9+
#include <libcron/Cron.h>
10+
#include <libcron/CronData.h>
11+
#include <chrono>
12+
#include <thread>
13+
using namespace std::chrono_literals;
14+
915
libcron::Cron cron;
1016
1117
cron.add_schedule("Hello from Cron", "* * * * * ?", [=](auto&) {
12-
std::cout << "Hello from libcron!" std::endl;
18+
std::cout << "Hello from libcron!" << std::endl;
1319
});
1420
```
1521

@@ -19,7 +25,7 @@ To trigger the execution of callbacks, one must call `libcron::Cron::tick` at le
1925
while(true)
2026
{
2127
cron.tick();
22-
std::this_thread::sleep_for(500mS);
28+
std::this_thread::sleep_for(500ms);
2329
}
2430
```
2531

0 commit comments

Comments
 (0)