-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrank.hpp
More file actions
46 lines (33 loc) · 816 Bytes
/
rank.hpp
File metadata and controls
46 lines (33 loc) · 816 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//
// Created by Łukasz Stachowicz on 03/09/2022.
//
#pragma once
#include "player_id.hpp"
#include "thread.hpp"
#include <map>
#include <mutex>
#include <queue>
#include <list>
namespace RPSGame
{
class Rank : public Thread
{
public:
explicit Rank() = default;
~Rank();
void rank(std::multimap<uint64_t, std::string>& rank);
void update(std::pair<PlayerId, uint64_t> entry);
protected:
void run() override;
void update(std::queue<std::pair<PlayerId, uint64_t>>& queue);
void load();
void save();
private:
std::multimap<uint64_t, PlayerId> m_rank_score;
std::mutex m_rank_lock;
std::multimap<uint64_t, std::string> m_rank;
std::mutex m_queue_lock;
std::condition_variable cv;
std::queue<std::pair<PlayerId, uint64_t> > m_queue;
};
}