Skip to content

Conversation

lukasz-plewa
Copy link

No description provided.

Copy link
Contributor

@ziobron ziobron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't work correctly for numOfReps = 1

ziobron@MBP:~/workspace/reveal.js/md.multithreading/module4$ ./plewa 1 100
Ping
Ping is finishing game. Num reps has reached 1
Game finished.

It was possible for me to end it with ping without a pong

Pong
Ping
Stop is finishing game - timeout.
Pong
Ping

on apple clang there is a data race - https://pastebin.pl/view/f5924827
but it's probably because of some differencies in stdlib. adding locks in ifs helps.

// TODO: wait to be used here + printing, reps incrementation, chainging turn to ping
this_thread::sleep_for(500ms);
opponentsTurn_.wait(l, [&] {return !isPingTurn_.load(); });
cout << "Pong" << endl;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consecutive number is not printed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants