Skip to content

Instantly share code, notes, and snippets.

@usagi
Created February 2, 2014 19:56
Show Gist options
  • Select an option

  • Save usagi/8773857 to your computer and use it in GitHub Desktop.

Select an option

Save usagi/8773857 to your computer and use it in GitHub Desktop.
#include <boost/thread.hpp>
#include <string>
#include <chrono>
#include <iostream>
int main()
{
bool is_running = true;
auto t = boost::thread([](bool& is_running)
{
std::string buffer;
std::getline(std::cin, buffer);
is_running = false;
}, std::ref(is_running));
while(is_running)
{
std::cerr << "*";
std::this_thread::sleep_for(std::chrono::seconds(1));
}
t.join();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment