Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module4 homework ping pong #53

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

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.

module4/exercises/03b_ping_pong_easier.cpp Outdated Show resolved Hide resolved
// 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