I've see other posts that ask a similar question, though I didn't see how the answers could help in my situation.
I've looked into using future and async, but all examples replace std::thread with it which I can't do because I'm using std::thread to run two functions at the same time.
char key;
int asciiValue;
while(1)
{
int timer;
int reset = 0;
std::thread x(Counter, reset);
std::thread y(getch);
/*
I need timer = Counter(reset);
I need key = getch();
*/
asciiValue = key;
if(asciiValue == 97)
{
std::cout << "a was pressed" << std::endl;
/*
Call Counter(reset); and getch(); again somehow
*/
}
}
How can I get
timer = std::thread x(Counter, reset);
and
key = std::thread y(getch);
to work?
Aucun commentaire:
Enregistrer un commentaire