Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- while (true) {
- unique_lock<mutex> lock(m_ActionQueue);
- while (q_ActionQueue.empty()) {
- m_cond_ActionQueue.wait(lock);
- }
- if (nextAction.time_since_epoch().count() != 0) {
- m_cond_ActionQueue.wait_until(lock,nextAction);
- }
- curTime = duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count();
- player_action a = q_ActionQueue.front();
- q_ActionQueue.pop_front();
- a.executeAt += 6000ms;
- a.actionsCompleted++;
- q_ActionQueue.push_back(a);
- nextAction = q_ActionQueue.front().executeAt;
- lock.unlock();
- cout << curTime << ": Action [" << a.player->name << "] Executed. Count: " << a.actionsCompleted << " over " << (curTime - duration_cast<milliseconds>(a.startedAt.time_since_epoch()).count())/1000 << " seconds." << endl;
- wss->send_player_message(a.player->connections,"Action Completed!");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement