Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
BlockAllocator.cpp
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4#include "Stroika/Foundation/StroikaPreComp.h"
5
7
8#include "BlockAllocator.h"
9
10using namespace Stroika::Foundation;
11using namespace Stroika::Foundation::Memory;
12using namespace Stroika::Foundation::Memory::Private_;
13using namespace Stroika::Foundation::Execution;
14
15using namespace Execution;
16
17/*
18 ********************************************************************************
19 *********** Memory::Private_::DoDeleteHandlingLocksExceptionsEtc_ **************
20 ********************************************************************************
21 */
22#if !qStroika_Foundation_Memory_BlockAllocator_UseLockFree_
23void Memory::Private_::DoDeleteHandlingLocksExceptionsEtc_ (void* p, void** staticNextLinkP) noexcept
24{
25 /*
26 * Logically this just does a lock acquire and assginemnt through pointers (swap). But
27 * it checks for thread abort exceptions, and supresses that if needed, since this is noexcept
28 * and can be used in DTOR. You can interrupt (abort) a thread while it deletes things.
29 */
30 try {
31 auto critSec = lock_guard{Private_::GetLock_ ()};
32 // push p onto the head of linked free list
33 (*(void**)p) = *staticNextLinkP;
34 *staticNextLinkP = p;
35 }
36 catch (const Execution::Thread::AbortException&) {
38 auto critSec = lock_guard{Private_::GetLock_ ()};
39 // push p onto the head of linked free list
40 (*(void**)p) = *staticNextLinkP;
41 *staticNextLinkP = p;
42 }
43}
44#endif