/*** Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved. File: Buffered.hpp Date: 2021-6-11 Author: Reece ***/ #pragma once namespace __audetail { struct BufferLock { Aurora::Memory::ByteBuffer *pThat; AuUInt8 *pIDC {}; inline BufferLock(Aurora::Memory::ByteBuffer *pThat) : pThat(pThat) { if (pThat) { pThat->PrivateUserDataToUtilityMutex()->Lock(); AuAtomicAdd(&pThat->uInUseCounter, 1u); AURORA_COMPILER_VOLATILE_BARRIER(); } } inline ~BufferLock() { if (this->pThat) { AuAtomicSub(&pThat->uInUseCounter, 1u); pThat->PrivateUserDataToUtilityMutex()->Unlock(); } } }; struct BufferAllocLock { Aurora::Memory::ByteBuffer *pThat; AuUInt8 *pIDC {}; inline BufferAllocLock(Aurora::Memory::ByteBuffer *pThat) : pThat(pThat) { if (pThat) { pThat->PrivateUserDataToUtilityMutex()->Lock(); AURORA_COMPILER_VOLATILE_BARRIER(); } } inline ~BufferAllocLock() { if (this->pThat) { pThat->PrivateUserDataToUtilityMutex()->Unlock(); } } }; } #include "BlobReader.hpp" #include "BlobSeekableReader.hpp" #include "BlobWriter.hpp" #include "BlobSeekableWriter.hpp" #include "ViewReader.hpp" #include "ViewSeekableReader.hpp" #include "ViewWriter.hpp" #include "ViewSeekableWriter.hpp"