Advertisement
Guest User

Untitled

a guest
Feb 17th, 2020
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. while (true) {
  2. unique_lock<mutex> lock(m_ActionQueue);
  3. while (q_ActionQueue.empty()) {
  4. m_cond_ActionQueue.wait(lock);
  5. }
  6. if (nextAction.time_since_epoch().count() != 0) {
  7. m_cond_ActionQueue.wait_until(lock,nextAction);
  8. }
  9.  
  10. curTime = duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count();
  11.  
  12. player_action a = q_ActionQueue.front();
  13. q_ActionQueue.pop_front();
  14.  
  15. a.executeAt += 6000ms;
  16. a.actionsCompleted++;
  17. q_ActionQueue.push_back(a);
  18.  
  19. nextAction = q_ActionQueue.front().executeAt;
  20.  
  21. lock.unlock();
  22.  
  23. cout << curTime << ": Action [" << a.player->name << "] Executed. Count: " << a.actionsCompleted << " over " << (curTime - duration_cast<milliseconds>(a.startedAt.time_since_epoch()).count())/1000 << " seconds." << endl;
  24. wss->send_player_message(a.player->connections,"Action Completed!");
  25.  
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement