IRC_SERVER
By @hyunjunk (hyunjun2372@gmail.com)
Loading...
Searching...
No Matches
ControlBlock.hpp
Go to the documentation of this file.
1#pragma once
2
5
6namespace IRCCore
7{
8
9namespace detail
10{
11
13{
17
20 , WeakRefCount(0)
21 , bExpired(false)
22 {
23 }
24};
25
26/** Do not use this class directly. Use MakeShared function.
27 *
28 * @details We will use placement new/deleteƍ
29 * The ControlBlock should not be deleted even after data's destructor is called.
30 * ControlBlock is deleted when both StrongRefCount and WeakRefCount are become 0.
31 *
32 * @warning "Never" change the order of RefCount field.
33 * This feature is implemented using the c++ standard that
34 * the address of the first member in structure is same as the address of the structure itself.
35 * (see WeakPtr() implementation)
36 * */
37template <typename T>
38struct ControlBlock : public FlexibleMemoryPoolingBase<ControlBlock<T>>
39{
41 ALIGNAS(ALIGNOF(T)) T data;
42
43public:
45 : RefCount()
46 {
47 }
48};
49
50} // namespace detail
51
52}
#define FORCEINLINE
Definition AttributeDefines.hpp:55
Base class for memory pooling with new/delete operator overloading.
Definition FlexibleMemoryPoolingBase.hpp:39
Definition ControlBlock.hpp:7
ALIGNAS(ALIGNOF(T)) T data
ControlBlock()
Definition ControlBlock.hpp:44
RefCountBase RefCount
Definition ControlBlock.hpp:40
Definition ControlBlock.hpp:13
bool bExpired
Definition ControlBlock.hpp:16
RefCountBase()
Definition ControlBlock.hpp:18
size_t StrongRefCount
Definition ControlBlock.hpp:14
size_t WeakRefCount
Definition ControlBlock.hpp:15