[+] AuIO::ReadAsync
[+] AuIO::WriteAsync
This commit is contained in:
parent
7001a97870
commit
42af66c841
@ -18,6 +18,7 @@ namespace Aurora::IO::CompletionGroup
|
||||
}
|
||||
|
||||
#include "CompletionGroup/ICompletionGroupWorkHandle.hpp"
|
||||
#include <Aurora/Debug/Debug.hpp>
|
||||
|
||||
namespace Aurora::IO
|
||||
{
|
||||
@ -93,4 +94,62 @@ namespace Aurora::IO
|
||||
|
||||
AURT_ADD_USR_DATA_EXP(this->ToCompletionGroupHandle());
|
||||
};
|
||||
|
||||
inline bool ReadAsync(const AuSPtr<IAsyncTransaction> &pTransaction,
|
||||
AuUInt64 uOffset,
|
||||
const AuSPtr<Memory::MemoryViewWrite> &memoryView,
|
||||
AuOptional<AuConsumer<AuUInt /*offset*/, AuUInt64 /*length*/>> callback = {},
|
||||
AuOptional<AuSPtr<CompletionGroup::ICompletionGroup>> pCompletionGroup = {})
|
||||
{
|
||||
SysCheckArgNotNull(pTransaction, false);
|
||||
|
||||
if (pCompletionGroup)
|
||||
{
|
||||
(void)pTransaction->TryAttachToCompletionGroup(pCompletionGroup.Value());
|
||||
}
|
||||
|
||||
if (callback)
|
||||
{
|
||||
auto pRet = AuMakeShared<IAsyncFinishedSubscriberFunctional>();
|
||||
if (!pRet)
|
||||
{
|
||||
SysPushErrorMemory();
|
||||
return false;
|
||||
}
|
||||
|
||||
pRet->OnAsyncFileOpFinishedFunctional = callback.Value();
|
||||
pTransaction->SetCallback(pRet);
|
||||
}
|
||||
|
||||
return pTransaction->StartRead(uOffset, memoryView);
|
||||
}
|
||||
|
||||
inline bool WriteAsync(const AuSPtr<IAsyncTransaction> &pTransaction,
|
||||
AuUInt64 uOffset,
|
||||
const AuSPtr<Memory::MemoryViewRead> &memoryView,
|
||||
AuOptional<AuConsumer<AuUInt /*offset*/, AuUInt64 /*length*/>> callback = {},
|
||||
AuOptional<AuSPtr<CompletionGroup::ICompletionGroup>> pCompletionGroup = {})
|
||||
{
|
||||
SysCheckArgNotNull(pTransaction, false);
|
||||
|
||||
if (pCompletionGroup)
|
||||
{
|
||||
(void)pTransaction->TryAttachToCompletionGroup(pCompletionGroup.Value());
|
||||
}
|
||||
|
||||
if (callback)
|
||||
{
|
||||
auto pRet = AuMakeShared<IAsyncFinishedSubscriberFunctional>();
|
||||
if (!pRet)
|
||||
{
|
||||
SysPushErrorMemory();
|
||||
return false;
|
||||
}
|
||||
|
||||
pRet->OnAsyncFileOpFinishedFunctional = callback.Value();
|
||||
pTransaction->SetCallback(pRet);
|
||||
}
|
||||
|
||||
return pTransaction->StartWrite(uOffset, memoryView);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user