AuroraRuntime/Include/Aurora/IO/Buffered/Buffered.hpp

76 lines
1.6 KiB
C++
Raw Normal View History

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
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-21 00:28:50 +00:00
AuAtomicAdd(&pThat->uInUseCounter, 1u);
2024-03-21 00:28:50 +00:00
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();
2024-03-21 00:28:50 +00:00
AURORA_COMPILER_VOLATILE_BARRIER();
}
}
inline ~BufferAllocLock()
{
if (this->pThat)
{
pThat->PrivateUserDataToUtilityMutex()->Unlock();
}
}
};
}
2021-06-27 21:25:29 +00:00
#include "BlobReader.hpp"
#include "BlobSeekableReader.hpp"
#include "BlobWriter.hpp"
#include "BlobSeekableWriter.hpp"
#include "ViewReader.hpp"
#include "ViewSeekableReader.hpp"
#include "ViewWriter.hpp"
#include "ViewSeekableWriter.hpp"