summaryrefslogtreecommitdiffstats
path: root/src/ChunkSender.h
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@outlook.com>2021-01-06 01:35:42 +0100
committerTiger Wang <ziwei.tiger@outlook.com>2021-01-12 13:34:34 +0100
commit054a89dd9e5d6819adede9d7ba781b69f98ff2f4 (patch)
tree820a104cae2d9e4ec912b0a1bd7debac52cf4cc9 /src/ChunkSender.h
parentConvert most calls to blocking GetHeight/GetBiomeAt to direct chunk accesses (diff)
downloadcuberite-054a89dd9e5d6819adede9d7ba781b69f98ff2f4.tar
cuberite-054a89dd9e5d6819adede9d7ba781b69f98ff2f4.tar.gz
cuberite-054a89dd9e5d6819adede9d7ba781b69f98ff2f4.tar.bz2
cuberite-054a89dd9e5d6819adede9d7ba781b69f98ff2f4.tar.lz
cuberite-054a89dd9e5d6819adede9d7ba781b69f98ff2f4.tar.xz
cuberite-054a89dd9e5d6819adede9d7ba781b69f98ff2f4.tar.zst
cuberite-054a89dd9e5d6819adede9d7ba781b69f98ff2f4.zip
Diffstat (limited to 'src/ChunkSender.h')
-rw-r--r--src/ChunkSender.h10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/ChunkSender.h b/src/ChunkSender.h
index be7b55b16..43246ad64 100644
--- a/src/ChunkSender.h
+++ b/src/ChunkSender.h
@@ -74,11 +74,10 @@ public:
void QueueSendChunkTo(int a_ChunkX, int a_ChunkZ, Priority a_Priority, cClientHandle * a_Client);
void QueueSendChunkTo(int a_ChunkX, int a_ChunkZ, Priority a_Priority, cChunkClientHandles a_Client);
- /** Removes the a_Client from all waiting chunk send operations */
- void RemoveClient(cClientHandle * a_Client);
-
protected:
+ using WeakClients = std::set<std::weak_ptr<cClientHandle>, std::owner_less<std::weak_ptr<cClientHandle>>>;
+
struct sChunkQueue
{
Priority m_Priority;
@@ -96,7 +95,7 @@ protected:
struct sSendChunk
{
cChunkCoords m_Chunk;
- std::unordered_set<cClientHandle *> m_Clients;
+ WeakClients m_Clients;
Priority m_Priority;
sSendChunk(cChunkCoords a_Chunk, Priority a_Priority) :
m_Chunk(a_Chunk),
@@ -114,7 +113,6 @@ protected:
std::priority_queue<sChunkQueue> m_SendChunks;
std::unordered_map<cChunkCoords, sSendChunk, cChunkCoordsHash> m_ChunkInfo;
cEvent m_evtQueue; // Set when anything is added to m_ChunksReady
- cEvent m_evtRemoved; // Set when removed clients are safe to be deleted
// Data about the chunk that is being sent:
// NOTE that m_BlockData[] is inherited from the cChunkDataCollector
@@ -132,7 +130,7 @@ protected:
virtual void BlockEntity (cBlockEntity * a_Entity) override;
/** Sends the specified chunk to all the specified clients */
- void SendChunk(int a_ChunkX, int a_ChunkZ, std::unordered_set<cClientHandle *> a_Clients);
+ void SendChunk(int a_ChunkX, int a_ChunkZ, const WeakClients & a_Clients);
} ;