[*] Improved pipe work awareness under protocol stack to allow for propagation of error conditions such that the top most interceptor can kill the pipe work
This commit is contained in:
parent
e0d7bbea01
commit
cdf5a499cb
@ -80,8 +80,9 @@ namespace Aurora::IO::Protocol
|
||||
/**
|
||||
* @brief Sends one tick down the protocol stack, regardless of how much data is written into the
|
||||
* next piece/interceptor, and regardless of if another read tick is required.
|
||||
* @return The error state of the top-most interceptor
|
||||
*/
|
||||
virtual void DoTick() = 0;
|
||||
virtual bool DoTick() = 0;
|
||||
|
||||
/**
|
||||
* @brief
|
||||
@ -101,5 +102,5 @@ namespace Aurora::IO::Protocol
|
||||
* @param pWork
|
||||
* @return
|
||||
*/
|
||||
AUKN_SYM AuSPtr<IProtocolStack> NewProtocolStackFromPipe(const AuSPtr<IIOPipeWork> &pWork, bool bAutoTick = true);
|
||||
AUKN_SYM AuSPtr<IProtocolStack> NewProtocolStackFromPipe(const AuSPtr<IIOPipeWork> &pWork, bool bAutoTick = true, bool bKillPipeOnFirstRootLevelFalse = true);
|
||||
}
|
@ -441,19 +441,29 @@ namespace Aurora::IO::Protocol
|
||||
return AuSPtr<AuByteBuffer>(this->pTopPiece, &this->pTopPiece->outputBuffer);
|
||||
}
|
||||
|
||||
void ProtocolStack::DoTick()
|
||||
bool ProtocolStack::DoTick()
|
||||
{
|
||||
if (!this->pSourceBufer)
|
||||
{
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!this->pBottomPiece)
|
||||
{
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
this->DoTick(this->pSourceBufer, {});
|
||||
if (!this->DoTick(this->pSourceBufer, {}))
|
||||
{
|
||||
if (auto pStack = AuTryLockMemoryType(this->pPipeWork))
|
||||
{
|
||||
pStack->TerminateOnThread(true);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ProtocolStack::DoTick(const AuSPtr<AuByteBuffer> &pRead, const AuSPtr<ProtocolPiece> &pPiece)
|
||||
@ -585,7 +595,7 @@ namespace Aurora::IO::Protocol
|
||||
return pStack;
|
||||
}
|
||||
|
||||
AUKN_SYM AuSPtr<IProtocolStack> NewProtocolStackFromPipe(const AuSPtr<IIOPipeWork> &pWork, bool bAutoTick)
|
||||
AUKN_SYM AuSPtr<IProtocolStack> NewProtocolStackFromPipe(const AuSPtr<IIOPipeWork> &pWork, bool bAutoTick, bool bKillPipeOnFirstRootLevelFalse)
|
||||
{
|
||||
if (!pWork)
|
||||
{
|
||||
@ -602,6 +612,8 @@ namespace Aurora::IO::Protocol
|
||||
|
||||
auto pWorkEx = AuStaticCast<IOPipeWork>(pWork);
|
||||
|
||||
pStack->pPipeWork = pWorkEx;
|
||||
|
||||
if (bAutoTick)
|
||||
{
|
||||
if (pWorkEx->pProtocolStack)
|
||||
|
@ -7,6 +7,8 @@
|
||||
***/
|
||||
#pragma once
|
||||
|
||||
#include "../AuIOPipeProcessor.hpp"
|
||||
|
||||
namespace Aurora::IO::Protocol
|
||||
{
|
||||
struct ProtocolPiece;
|
||||
@ -15,7 +17,7 @@ namespace Aurora::IO::Protocol
|
||||
{
|
||||
~ProtocolStack();
|
||||
|
||||
void DoTick() override;
|
||||
bool DoTick() override;
|
||||
bool DoTick(const AuSPtr<AuByteBuffer> &read, const AuSPtr<ProtocolPiece> &pPiece);
|
||||
|
||||
AuSPtr<IProtocolPiece> AppendInterceptor(const AuSPtr<IProtocolInterceptor> &pInterceptor, AuUInt uOutputBufferSize) override;
|
||||
@ -46,5 +48,7 @@ namespace Aurora::IO::Protocol
|
||||
AuSPtr<ProtocolPiece> pTopPiece;
|
||||
|
||||
bool bWrittenEnd {};
|
||||
|
||||
AuWPtr<AuIO::IOPipeWork> pPipeWork;
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue
Block a user