Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // w samolocie
- void movePlane(Plane &plane, Que &que) {
- while(condition) {
- plane.move();
- if( (plane.getPosition().x >= (que.getPosition().x + 1)) && (plane.getPosition().x <= (que.getPosition().x + 1 + que.getLength())) ) {
- que.addPlane(plane);
- std::unique_lock<std::mutex> que_lock(m_que);
- cv_que.wait(que_lock);
- }
- if(plane.getPosition().x <= que.getPosition().x) {
- if(plane.getPosition().x == (maxW / 2) + 10) {
- if(first == true) {
- plane.setVDirection(0);
- plane.setRunwayNumber(1);
- first = false;
- }
- else if(second == true) {
- plane.setVDirection(1);
- plane.setRunwayNumber(2);
- second = false;
- }
- else if(third == true) {
- plane.setVDirection(2);
- plane.setRunwayNumber(3);
- third = false;
- }
- }
- if(plane.getPosition().x == (maxW / 2) + 1) {
- std::unique_lock<std::mutex> lk(m_first);
- cv_first.wait(lk);
- }
- else if(plane.getPosition().x == (maxW / 2) + 1) {
- std::unique_lock<std::mutex> lk(m_second);
- cv_second.wait(lk);
- }
- else if(plane.getPosition().x == (maxW / 2) + 1) {
- std::unique_lock<std::mutex> lk(m_third);
- cv_third.wait(lk);
- }
- }
- std::this_thread::sleep_for(std::chrono::milliseconds(500));
- }
- }
- //*************************************************************************************
- void landing(Que &que) {
- while(condition) {
- if(first == true) {
- cv_que.notify_all();
- que.popPlane();
- }
- if(second == true) {
- cv_que.notify_all();
- que.popPlane();
- }
- if(third == true) {
- cv_que.notify_all();
- que.popPlane();
- }
- std::this_thread::sleep_for(std::chrono::milliseconds(100));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement