Files
UnrealEngineUWP/Engine/Source/Programs/UnrealBuildTool/System/ActionExecutor.cs
Ben Marsh 7e26c34d2b EpicGames.Core: Deprecate legacy log methods to prefer structured logging interface.
#preflight 640a23d928026468d9de7cbd

[CL 24580590 by Ben Marsh in ue5-main branch]
2023-03-09 14:51:40 -05:00

68 lines
1.4 KiB
C#

// Copyright Epic Games, Inc. All Rights Reserved.
using EpicGames.Core;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Reflection;
namespace UnrealBuildTool
{
abstract class ActionExecutor : IDisposable
{
public abstract string Name
{
get;
}
static protected double MemoryPerActionBytesOverride
{
get;
private set;
} = 0.0;
readonly LogEventParser Parser;
public ActionExecutor(ILogger Logger)
{
Parser = new LogEventParser(Logger);
Parser.AddMatchersFromAssembly(Assembly.GetExecutingAssembly());
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposing)
{
if (disposing)
{
Parser.Dispose();
}
}
/// <summary>
/// Allow targets to override the expected amount of memory required for compiles, used to control the number
/// of parallel action processes.
/// </summary>
/// <param name="MemoryPerActionOverrideGB"></param>
public static void SetMemoryPerActionOverride(double MemoryPerActionOverrideGB)
{
MemoryPerActionBytesOverride = Math.Max(MemoryPerActionBytesOverride, MemoryPerActionOverrideGB * 1024 * 1024 * 1024);
}
public abstract bool ExecuteActions(IEnumerable<LinkedAction> ActionsToExecute, ILogger Logger);
protected void WriteToolOutput(string Line)
{
lock (Parser)
{
Parser.WriteLine(Line);
}
}
}
}