title: How to stop execution of an async function when input is recieved in C++
body: <p>As title states i'm testing some stuff with  standard library and i got confused on how to make sure when exactly input was recieved. My code looks like this:</p>
  
  <pre><code>static bool s_cinGet = false;
  
  std::string CycleWords(std::vector&lt;std::string&gt; Words)
  {
      unsigned int i = 0;
      while (!s_cinGet)
      {
          system("cls");
          std::cout &lt;&lt; Words[i] &lt;&lt; std::endl;
          i++;
          i = i % Words.size();
          std::this_thread::sleep_for(std::chrono::milliseconds(10));
      }
      if (i != 0) i--;
      else i = Words.size() - 1;
      return Words[i];
  }
  
  int main()
  {
      std::vector&lt;std::string&gt; Words = { "Tunti", "Triliteral", "Carl" };
  
      while (true)
      {
          s_cinGet = false;
          auto future = std::async(CycleWords, Words);
          std::cin.get();
          s_cinGet = true;
  
          std::string word = future.get();
  
          //system("cls");
          std::cout &lt;&lt; word &lt;&lt; std::endl;
      }
      std::cin.get();
      return 0;
  }
  </code></pre>
  
  <p>The program is really simple. It cycles through some words till user presses any key and prints the last word. I want to make sure that the last word was exactly the same word when the user pressed a key. Any suggestions are appreciated.</p>