Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void boarding(Runway &runway, Que &passQue, int i) {
- while(condition) {
- if(runway.getLength() > 0 && runway.getFreePlaces() > 0) {
- std::unique_lock<std::mutex> que_lock(m_data);
- cv_data.wait(que_lock, []{return ready;});
- cv_passQue.notify_all();
- runway.addPassenger(passQue.popPassenger());
- processed = true;
- }
- std::this_thread::sleep_for(std::chrono::milliseconds(100));
- }
- }
- void getPassenger(Que &passque) {
- while(condition) {
- // ready = false;
- if(passque.getPassengersLength() > 0){
- processed = false;
- std::lock_guard<std::mutex> lk(m_data);
- ready = true;
- cv_data.notify_one();
- std::unique_lock<std::mutex> l(m_data);
- cv_data.wait(l, []{return processed;});
- }
- std::this_thread::sleep_for(std::chrono::milliseconds(100));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement