DDraceNetwork Docs
snap_id_pool.h
Go to the documentation of this file.
1/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */
2/* If you are missing that file, acquire a complete release at teeworlds.com. */
3
4#ifndef ENGINE_SERVER_SNAP_ID_POOL_H
5#define ENGINE_SERVER_SNAP_ID_POOL_H
6
8{
9 enum
10 {
11 MAX_IDS = 32 * 1024,
12 };
13
14 // State of a Snap ID
15 enum
16 {
20 };
21
22 class CID
23 {
24 public:
25 short m_Next;
26 short m_State; // 0 = free, 1 = allocated, 2 = timed
28 };
29
31
37
38public:
40
41 void Reset();
42 void RemoveFirstTimeout();
43 int NewId();
44 void TimeoutIds();
45 void FreeId(int Id);
46};
47
48#endif
Definition: snap_id_pool.h:23
short m_Next
Definition: snap_id_pool.h:25
int m_Timeout
Definition: snap_id_pool.h:27
short m_State
Definition: snap_id_pool.h:26
Definition: snap_id_pool.h:8
int m_InUsage
Definition: snap_id_pool.h:36
CSnapIdPool()
Definition: snap_id_pool.cpp:8
void TimeoutIds()
Definition: snap_id_pool.cpp:67
void FreeId(int Id)
Definition: snap_id_pool.cpp:74
int m_FirstFree
Definition: snap_id_pool.h:32
int m_LastTimed
Definition: snap_id_pool.h:34
int m_Usage
Definition: snap_id_pool.h:35
int m_FirstTimed
Definition: snap_id_pool.h:33
@ MAX_IDS
Definition: snap_id_pool.h:11
int NewId()
Definition: snap_id_pool.cpp:46
void RemoveFirstTimeout()
Definition: snap_id_pool.cpp:29
@ ID_TIMED
Definition: snap_id_pool.h:19
@ ID_FREE
Definition: snap_id_pool.h:17
@ ID_ALLOCATED
Definition: snap_id_pool.h:18
CID m_aIds[MAX_IDS]
Definition: snap_id_pool.h:30
void Reset()
Definition: snap_id_pool.cpp:13