Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.19 KB | None | 0 0
  1. // w samolocie
  2. void movePlane(Plane &plane, Que &que) {
  3. while(condition) {
  4. plane.move();
  5.  
  6. if( (plane.getPosition().x >= (que.getPosition().x + 1)) && (plane.getPosition().x <= (que.getPosition().x + 1 + que.getLength())) ) {
  7. que.addPlane(plane);
  8. std::unique_lock<std::mutex> que_lock(m_que);
  9. cv_que.wait(que_lock);
  10. }
  11.  
  12. if(plane.getPosition().x <= que.getPosition().x) {
  13.  
  14. if(plane.getPosition().x == (maxW / 2) + 10) {
  15. if(first == true) {
  16. plane.setVDirection(0);
  17. plane.setRunwayNumber(1);
  18. first = false;
  19. }
  20. else if(second == true) {
  21. plane.setVDirection(1);
  22. plane.setRunwayNumber(2);
  23. second = false;
  24. }
  25.  
  26. else if(third == true) {
  27. plane.setVDirection(2);
  28. plane.setRunwayNumber(3);
  29. third = false;
  30. }
  31. }
  32.  
  33. if(plane.getPosition().x == (maxW / 2) + 1) {
  34. std::unique_lock<std::mutex> lk(m_first);
  35. cv_first.wait(lk);
  36. }
  37.  
  38. else if(plane.getPosition().x == (maxW / 2) + 1) {
  39. std::unique_lock<std::mutex> lk(m_second);
  40. cv_second.wait(lk);
  41. }
  42.  
  43. else if(plane.getPosition().x == (maxW / 2) + 1) {
  44. std::unique_lock<std::mutex> lk(m_third);
  45. cv_third.wait(lk);
  46. }
  47. }
  48.  
  49. std::this_thread::sleep_for(std::chrono::milliseconds(500));
  50. }
  51.  
  52. }
  53. //*************************************************************************************
  54. void landing(Que &que) {
  55. while(condition) {
  56. if(first == true) {
  57. cv_que.notify_all();
  58. que.popPlane();
  59. }
  60. if(second == true) {
  61. cv_que.notify_all();
  62. que.popPlane();
  63. }
  64. if(third == true) {
  65. cv_que.notify_all();
  66. que.popPlane();
  67. }
  68. std::this_thread::sleep_for(std::chrono::milliseconds(100));
  69. }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement