[+] AuOutputOfs OutputOfResult should have a lock for multithread consumption
This commit is contained in:
parent
830286de46
commit
3472665c9f
@ -18,12 +18,16 @@ namespace Aurora::Processes
|
||||
|
||||
struct OutputOfResult
|
||||
{
|
||||
bool bFailed {};
|
||||
bool bNoStart {};
|
||||
AuString strStdout;
|
||||
AuString strStderr;
|
||||
AuUInt uExitCode {};
|
||||
AuSInt sExitCode {};
|
||||
// Lockable object for reading strStdout and strStderr between threads.
|
||||
/*AuFutexMutex*/ Aurora::Threading::Waitables::FutexWaitableNoVTblMovable lock;
|
||||
bool bFailed { };
|
||||
bool bNoStart { };
|
||||
bool bPipeOutOOM { };
|
||||
bool bPipeErrOOM { };
|
||||
AuString strStdout { };
|
||||
AuString strStderr { };
|
||||
AuUInt uExitCode { };
|
||||
AuSInt sExitCode { };
|
||||
};
|
||||
|
||||
struct IAsyncOutputOf
|
||||
@ -39,9 +43,13 @@ namespace Aurora::Processes
|
||||
AURT_ADD_USR_DATA_EXP(this->ToCompletionGroupHandle());
|
||||
};
|
||||
|
||||
// Thread-local blocking
|
||||
AUKN_SYM OutputOfResult OutputOf(StartupParameters &¶meters,
|
||||
AuOptional<Memory::MemoryViewRead> toSend);
|
||||
AuOptional<Memory::MemoryViewRead> toSend /* TODO: not yet implemented */);
|
||||
|
||||
// Thread-local async
|
||||
// See: IOSleep.hpp, other ILoopSource yields to enter an alertable state, ILoopQueue to enter an alertable state, et al.
|
||||
// Will attach to a async worker thread, if under an AuAsync thread.
|
||||
AUKN_SYM AuSPtr<IAsyncOutputOf> OutputOfAsync(StartupParameters &¶meters,
|
||||
const AuSPtr<IAsyncCallbacks> &pCallbacks);
|
||||
}
|
@ -612,7 +612,20 @@ namespace Aurora::Processes
|
||||
|
||||
if (length)
|
||||
{
|
||||
pResult->result.strStdout += AuString(pResult->stdOutPipe.begin(), pResult->stdOutPipe.begin() + length);
|
||||
try
|
||||
{
|
||||
AU_LOCK_GUARD(pResult->result.lock);
|
||||
pResult->result.strStdout += AuString(pResult->stdOutPipe.begin(), pResult->stdOutPipe.begin() + length);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
SysPushErrorOutOfSpaceMemory();
|
||||
pResult->result.bPipeOutOOM = true;
|
||||
AuResetMember(pResult->pTransactionA);
|
||||
AuResetMember(pResult->pTransactionSourceA);
|
||||
return;
|
||||
}
|
||||
|
||||
if (pResult->pCallbacks)
|
||||
{
|
||||
pResult->pCallbacks->OnPipeData();
|
||||
@ -641,7 +654,20 @@ namespace Aurora::Processes
|
||||
|
||||
if (length)
|
||||
{
|
||||
pResult->result.strStderr += AuString(pResult->stdErrPipe.begin(), pResult->stdErrPipe.begin() + length);
|
||||
try
|
||||
{
|
||||
AU_LOCK_GUARD(pResult->result.lock);
|
||||
pResult->result.strStderr += AuString(pResult->stdErrPipe.begin(), pResult->stdErrPipe.begin() + length);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
SysPushErrorOutOfSpaceMemory();
|
||||
pResult->result.bPipeErrOOM = true;
|
||||
AuResetMember(pResult->pTransactionB);
|
||||
AuResetMember(pResult->pTransactionSourceB);
|
||||
return;
|
||||
}
|
||||
|
||||
if (pResult->pCallbacks)
|
||||
{
|
||||
pResult->pCallbacks->OnPipeData();
|
||||
|
Loading…
Reference in New Issue
Block a user