Ark Server API (ASA) - Wiki
Loading...
Searching...
No Matches
FMonitoredProcess Class Reference

#include <MonitoredProcess.h>

+ Inheritance diagram for FMonitoredProcess:
+ Collaboration diagram for FMonitoredProcess:

Public Member Functions

 FMonitoredProcess (const FString &InURL, const FString &InParams, bool InHidden, bool InCreatePipes=true)
 
 FMonitoredProcess (const FString &InURL, const FString &InParams, const FString &InWorkingDir, bool InHidden, bool InCreatePipes=true)
 
virtual ~FMonitoredProcess ()
 
void Cancel (bool InKillTree=false)
 
FTimespan GetDuration () const
 
FProcHandle GetProcessHandle () const
 
FString GetCommandline () const
 
bool Update ()
 
virtual bool Launch ()
 
void SetSleepInterval (float InSleepInterval)
 
FSimpleDelegateOnCanceled ()
 
FOnMonitoredProcessCompletedOnCompleted ()
 
FOnMonitoredProcessOutputOnOutput ()
 
int GetReturnCode () const
 
const FStringGetFullOutputWithoutDelegate () const
 
virtual bool Init () override
 
virtual uint32 Run () override
 
virtual void Stop () override
 
virtual void Exit () override
 
virtual FSingleThreadRunnableGetSingleThreadInterface () override
 
- Public Member Functions inherited from FRunnable
virtual ~FRunnable ()
 

Protected Member Functions

void Tick () override
 
void ProcessOutput (const FString &Output)
 
void TickInternal ()
 
 TSAN_ATOMIC (bool) bIsRunning
 

Protected Attributes

bool Canceling = false
 
FDateTime EndTime
 
bool Hidden = false
 
bool KillTree = false
 
FString Params
 
FProcHandle ProcessHandle
 
voidReadPipe = nullptr
 
int ReturnCode = 0
 
FDateTime StartTime { 0 }
 
FRunnableThreadThread = nullptr
 
FString URL
 
FString WorkingDir
 
voidWritePipe = nullptr
 
bool bCreatePipes = false
 
float SleepInterval = 0.01f
 
FString OutputBuffer
 
FSimpleDelegate CanceledDelegate
 
FOnMonitoredProcessCompleted CompletedDelegate
 
FOnMonitoredProcessOutput OutputDelegate
 

Additional Inherited Members

- Private Member Functions inherited from FSingleThreadRunnable
virtual ~FSingleThreadRunnable ()
 

Detailed Description

Implements an external process that can be monitored.

Definition at line 35 of file MonitoredProcess.h.

Constructor & Destructor Documentation

◆ FMonitoredProcess() [1/2]

FMonitoredProcess::FMonitoredProcess ( const FString & InURL,
const FString & InParams,
bool InHidden,
bool InCreatePipes = true )

Creates a new monitored process.

Parameters
InURLThe URL of the executable to launch.
InParamsThe command line parameters.
InHiddenWhether the window of the process should be hidden.
InCreatePipesWhether the output should be redirected to the caller.

◆ FMonitoredProcess() [2/2]

FMonitoredProcess::FMonitoredProcess ( const FString & InURL,
const FString & InParams,
const FString & InWorkingDir,
bool InHidden,
bool InCreatePipes = true )

Creates a new monitored process.

Parameters
InURLThe URL of the executable to launch.
InParamsThe command line parameters.
InHiddenWhether the window of the process should be hidden.
InWorkingDirThe URL of the working dir where the executable should launch.
InCreatePipesWhether the output should be redirected to the caller.

◆ ~FMonitoredProcess()

virtual FMonitoredProcess::~FMonitoredProcess ( )
virtual

Destructor.

Member Function Documentation

◆ Cancel()

void FMonitoredProcess::Cancel ( bool InKillTree = false)
inline

Cancels the process.

Parameters
InKillTreeWhether to kill the entire process tree when canceling this process.

Definition at line 71 of file MonitoredProcess.h.

+ Here is the caller graph for this function:

◆ Exit()

virtual void FMonitoredProcess::Exit ( )
inlineoverridevirtual

Exits the runnable object.

Called in the context of the aggregating thread to perform any cleanup.

See also
Init, Run, Stop

Reimplemented from FRunnable.

Definition at line 189 of file MonitoredProcess.h.

◆ GetCommandline()

FString FMonitoredProcess::GetCommandline ( ) const
inline

Returns the commandline of the process which will be executed if Launch is called

Definition at line 97 of file MonitoredProcess.h.

◆ GetDuration()

FTimespan FMonitoredProcess::GetDuration ( ) const

Gets the duration of time that the task has been running.

Returns
Time duration.

◆ GetFullOutputWithoutDelegate()

const FString & FMonitoredProcess::GetFullOutputWithoutDelegate ( ) const
inline

Returns the full output, wihtout needing to hookup a delegate and buffer it externally. Note that if OutputDelegate is bound, this will not have the entire output

Definition at line 168 of file MonitoredProcess.h.

◆ GetProcessHandle()

FProcHandle FMonitoredProcess::GetProcessHandle ( ) const
inline

Gets the Process Handle. The instance can be invalid if the process was not created.

Returns
The Process Handle

Definition at line 89 of file MonitoredProcess.h.

◆ GetReturnCode()

int FMonitoredProcess::GetReturnCode ( ) const
inline

Returns the return code from the exited process

Returns
Process return code

Definition at line 159 of file MonitoredProcess.h.

◆ GetSingleThreadInterface()

virtual FSingleThreadRunnable * FMonitoredProcess::GetSingleThreadInterface ( )
inlineoverridevirtual

Gets single thread interface pointer used for ticking this runnable when multi-threading is disabled. If the interface is not implemented, this runnable will not be ticked when FPlatformProcess::SupportsMultithreading() is false.

Returns
Pointer to the single thread interface or nullptr if not implemented.

Reimplemented from FRunnable.

Definition at line 191 of file MonitoredProcess.h.

◆ Init()

virtual bool FMonitoredProcess::Init ( )
inlineoverridevirtual

Initializes the runnable object.

This method is called in the context of the thread object that aggregates this, not the thread that passes this runnable to a new thread.

Returns
True if initialization was successful, false otherwise
See also
Run, Stop, Exit

Reimplemented from FRunnable.

Definition at line 177 of file MonitoredProcess.h.

◆ Launch()

virtual bool FMonitoredProcess::Launch ( )
virtual

Launches the process.

Reimplemented in FSerializedUATProcess.

◆ OnCanceled()

FSimpleDelegate & FMonitoredProcess::OnCanceled ( )
inline

Returns a delegate that is executed when the process has been canceled.

Returns
The delegate.

Definition at line 129 of file MonitoredProcess.h.

◆ OnCompleted()

FOnMonitoredProcessCompleted & FMonitoredProcess::OnCompleted ( )
inline

Returns a delegate that is executed when a monitored process completed.

Returns
The delegate.

Definition at line 139 of file MonitoredProcess.h.

◆ OnOutput()

FOnMonitoredProcessOutput & FMonitoredProcess::OnOutput ( )
inline

Returns a delegate that is executed when a monitored process produces output.

Returns
The delegate.

Definition at line 149 of file MonitoredProcess.h.

◆ ProcessOutput()

void FMonitoredProcess::ProcessOutput ( const FString & Output)
protected

Processes the given output string.

Parameters
OutputThe output string to process.

◆ Run()

virtual uint32 FMonitoredProcess::Run ( )
overridevirtual

Runs the runnable object.

This is where all per object thread work is done. This is only called if the initialization was successful.

Returns
The exit code of the runnable object
See also
Init, Stop, Exit

Implements FRunnable.

◆ SetSleepInterval()

void FMonitoredProcess::SetSleepInterval ( float InSleepInterval)
inline

Sets the sleep interval to be used in the main thread loop.

Parameters
InSleepIntervalThe Sleep interval to use.

Definition at line 117 of file MonitoredProcess.h.

◆ Stop()

virtual void FMonitoredProcess::Stop ( )
inlineoverridevirtual

Stops the runnable object.

This is called if a thread is requested to terminate early.

See also
Init, Run, Exit

Reimplemented from FRunnable.

Definition at line 184 of file MonitoredProcess.h.

+ Here is the call graph for this function:

◆ Tick()

void FMonitoredProcess::Tick ( )
overrideprotectedvirtual

◆ TickInternal()

void FMonitoredProcess::TickInternal ( )
protected

◆ TSAN_ATOMIC()

FMonitoredProcess::TSAN_ATOMIC ( bool )
protected

◆ Update()

bool FMonitoredProcess::Update ( )

Checks whether the process is still running. In single threaded mode, this will tick the thread processing

Returns
true if the process is running, false otherwise.

Member Data Documentation

◆ bCreatePipes

bool FMonitoredProcess::bCreatePipes = false
protected

Definition at line 257 of file MonitoredProcess.h.

◆ CanceledDelegate

FSimpleDelegate FMonitoredProcess::CanceledDelegate
protected

Definition at line 268 of file MonitoredProcess.h.

◆ Canceling

bool FMonitoredProcess::Canceling = false
protected

Definition at line 215 of file MonitoredProcess.h.

◆ CompletedDelegate

FOnMonitoredProcessCompleted FMonitoredProcess::CompletedDelegate
protected

Definition at line 271 of file MonitoredProcess.h.

◆ EndTime

FDateTime FMonitoredProcess::EndTime
protected

Definition at line 218 of file MonitoredProcess.h.

◆ Hidden

bool FMonitoredProcess::Hidden = false
protected

Definition at line 221 of file MonitoredProcess.h.

◆ KillTree

bool FMonitoredProcess::KillTree = false
protected

Definition at line 224 of file MonitoredProcess.h.

◆ OutputBuffer

FString FMonitoredProcess::OutputBuffer
protected

Definition at line 263 of file MonitoredProcess.h.

◆ OutputDelegate

FOnMonitoredProcessOutput FMonitoredProcess::OutputDelegate
protected

Definition at line 274 of file MonitoredProcess.h.

◆ Params

FString FMonitoredProcess::Params
protected

Definition at line 227 of file MonitoredProcess.h.

◆ ProcessHandle

FProcHandle FMonitoredProcess::ProcessHandle
protected

Definition at line 230 of file MonitoredProcess.h.

◆ ReadPipe

void* FMonitoredProcess::ReadPipe = nullptr
protected

Definition at line 233 of file MonitoredProcess.h.

◆ ReturnCode

int FMonitoredProcess::ReturnCode = 0
protected

Definition at line 236 of file MonitoredProcess.h.

◆ SleepInterval

float FMonitoredProcess::SleepInterval = 0.01f
protected

Definition at line 260 of file MonitoredProcess.h.

◆ StartTime

FDateTime FMonitoredProcess::StartTime { 0 }
protected

Definition at line 239 of file MonitoredProcess.h.

◆ Thread

FRunnableThread* FMonitoredProcess::Thread = nullptr
protected

Definition at line 242 of file MonitoredProcess.h.

◆ URL

FString FMonitoredProcess::URL
protected

Definition at line 248 of file MonitoredProcess.h.

◆ WorkingDir

FString FMonitoredProcess::WorkingDir
protected

Definition at line 251 of file MonitoredProcess.h.

◆ WritePipe

void* FMonitoredProcess::WritePipe = nullptr
protected

Definition at line 254 of file MonitoredProcess.h.


The documentation for this class was generated from the following file: