Created
March 8, 2022 17:33
-
-
Save nikcleju/15875bcfe366ca17be6518c3e8ed593f to your computer and use it in GitHub Desktop.
Xeus-cling keep alive in Mybinder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <thread> | |
| #include <chrono> | |
| #include "xcpp/xdisplay.hpp" | |
| void threadFunc() | |
| { | |
| using namespace std::chrono_literals; | |
| int repeat = 30; | |
| for (int i=0; i < repeat; i++) | |
| { | |
| std::cout << "(Keep alive "<< i+1 << "/" << repeat << ")" << std::endl << std::flush; | |
| // Sleep this thread for 300 Seconds | |
| std::this_thread::sleep_for(290s); //300000ms = 300s = 5 min | |
| //xcpp::clear_output(true); // prevents flickering | |
| } | |
| std::cout << "(Keep alive finished)"; | |
| } | |
| //threadFunc() | |
| std::thread th(&threadFunc); | |
| th.detach(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment