2021-06-27 21:25:29 +00:00
|
|
|
/***
|
|
|
|
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
|
|
|
|
|
|
|
File: Buffered.hpp
|
|
|
|
Date: 2021-6-11
|
|
|
|
Author: Reece
|
|
|
|
***/
|
|
|
|
#pragma once
|
|
|
|
|
2024-03-18 08:36:11 +00:00
|
|
|
namespace __audetail
|
|
|
|
{
|
|
|
|
struct BufferLock
|
|
|
|
{
|
|
|
|
Aurora::Memory::ByteBuffer *pThat;
|
|
|
|
AuUInt8 *pIDC {};
|
|
|
|
|
|
|
|
inline BufferLock(Aurora::Memory::ByteBuffer *pThat) :
|
|
|
|
pThat(pThat)
|
|
|
|
{
|
|
|
|
if (pThat)
|
|
|
|
{
|
2024-03-21 00:28:50 +00:00
|
|
|
pThat->PrivateUserDataToUtilityMutex()->Lock();
|
2024-03-18 08:36:11 +00:00
|
|
|
|
2024-03-21 00:28:50 +00:00
|
|
|
AuAtomicAdd(&pThat->uInUseCounter, 1u);
|
2024-03-18 08:36:11 +00:00
|
|
|
|
2024-03-21 00:28:50 +00:00
|
|
|
AURORA_COMPILER_VOLATILE_BARRIER();
|
2024-03-18 08:36:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
2024-03-21 00:28:50 +00:00
|
|
|
|
|
|
|
AURORA_COMPILER_VOLATILE_BARRIER();
|
2024-03-18 08:36:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
inline ~BufferAllocLock()
|
|
|
|
{
|
|
|
|
if (this->pThat)
|
|
|
|
{
|
|
|
|
pThat->PrivateUserDataToUtilityMutex()->Unlock();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-06-27 21:25:29 +00:00
|
|
|
#include "BlobReader.hpp"
|
2024-03-07 06:49:23 +00:00
|
|
|
#include "BlobSeekableReader.hpp"
|
2022-12-12 23:50:05 +00:00
|
|
|
#include "BlobWriter.hpp"
|
2024-03-07 06:49:23 +00:00
|
|
|
#include "BlobSeekableWriter.hpp"
|
2022-12-12 23:50:05 +00:00
|
|
|
|
|
|
|
#include "ViewReader.hpp"
|
2024-03-07 06:49:23 +00:00
|
|
|
#include "ViewSeekableReader.hpp"
|
|
|
|
#include "ViewWriter.hpp"
|
|
|
|
#include "ViewSeekableWriter.hpp"
|