Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Philosopher::AcquireForks() {
- if (seat_ == 0) {
- left_fork_.lock();
- right_fork_.lock();
- } else {
- right_fork_.lock();
- left_fork_.lock();
- }
- }
- void Philosopher::Eat() {
- table_.AccessPlate(seat_);
- table_.AccessPlate(table_.ToRight(seat_));
- ++eat_count_;
- }
- // Releases left_fork_ and right_fork_
- void Philosopher::ReleaseForks() {
- left_fork_.unlock();
- right_fork_.unlock();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement