| 1 | #include <thread> |
|---|---|
| 2 | #include <chrono> |
| 3 | |
| 4 | void usleep_helper(unsigned int usec) { |
| 5 | // Break here in the helper |
| 6 | std::this_thread::sleep_for(rtime: std::chrono::duration<unsigned int, std::milli>(usec)); |
| 7 | } |
| 8 | |
| 9 | void *background_thread(void *arg) { |
| 10 | (void) arg; |
| 11 | for (;;) { |
| 12 | usleep_helper(usec: 2); |
| 13 | } |
| 14 | } |
| 15 | |
| 16 | int main(void) { |
| 17 | unsigned int main_usec = 1; |
| 18 | std::thread main_thread(background_thread, nullptr); // Set bkpt here to get started |
| 19 | for (;;) { |
| 20 | usleep_helper(usec: main_usec); |
| 21 | } |
| 22 | } |
| 23 |
