blob: 3048e48a25ba072fe47d7fc2010370a044cbb40c (
plain)
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
47
48
49
50
51
|
#include "borrowed-ptr.inl"
namespace floormat::detail_bptr {
void control_block::decrement(control_block*& blk) noexcept
{
auto c2 = --blk->_hard_count;
fm_bptr_assert(c2 != (uint32_t)-1);
if (c2 == 0)
{
delete blk->_ptr;
blk->_ptr = nullptr;
}
auto c = --blk->_soft_count;
fm_bptr_assert(c != (uint32_t)-1);
if (c == 0)
{
fm_bptr_assert(!blk->_ptr);
delete blk;
}
blk = nullptr;
}
void control_block::weak_decrement(control_block*& blk) noexcept
{
if (!blk)
return;
fm_bptr_assert(blk->_hard_count < blk->_soft_count);
auto c = --blk->_soft_count;
//fm_bptr_assert(c != (uint32_t)-1);
if (c == 0)
{
fm_bptr_assert(!blk->_ptr);
delete blk;
}
blk = nullptr;
}
} // namespace floormat::detail_bptr
namespace floormat {
bptr_base::~bptr_base() noexcept = default;
bptr_base::bptr_base() noexcept = default;
bptr_base::bptr_base(const bptr_base&) noexcept = default;
bptr_base::bptr_base(bptr_base&&) noexcept = default;
bptr_base& bptr_base::operator=(const bptr_base&) noexcept = default;
bptr_base& bptr_base::operator=(bptr_base&&) noexcept = default;
} // namespace floormat
|