Pools admin log lists (#11462)
Co-authored-by: metalgearsloth <metalgearsloth@gmail.com>
This commit is contained in:
@@ -8,8 +8,10 @@ using Content.Shared.Administration;
|
||||
using Content.Shared.Administration.Logs;
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Shared.Eui;
|
||||
using Microsoft.Extensions.ObjectPool;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Utility;
|
||||
using static Content.Shared.Administration.Logs.AdminLogsEuiMsg;
|
||||
|
||||
namespace Content.Server.Administration.Logs;
|
||||
@@ -29,6 +31,9 @@ public sealed class AdminLogsEui : BaseEui
|
||||
private CancellationTokenSource _logSendCancellation = new();
|
||||
private LogFilter _filter;
|
||||
|
||||
private DefaultObjectPool<List<SharedAdminLog>> _adminLogListPool =
|
||||
new(new ListPolicy<SharedAdminLog>());
|
||||
|
||||
public AdminLogsEui()
|
||||
{
|
||||
IoCManager.InjectDependencies(this);
|
||||
@@ -140,13 +145,8 @@ public sealed class AdminLogsEui : BaseEui
|
||||
var stopwatch = new Stopwatch();
|
||||
stopwatch.Start();
|
||||
|
||||
// TODO ADMIN LOGS array pool
|
||||
List<SharedAdminLog> logs = default!;
|
||||
|
||||
await Task.Run(async () =>
|
||||
{
|
||||
logs = await _adminLogs.All(_filter);
|
||||
}, _filter.CancellationToken);
|
||||
var logs = await Task.Run(async () => await _adminLogs.All(_filter, _adminLogListPool.Get),
|
||||
_filter.CancellationToken);
|
||||
|
||||
if (logs.Count > 0)
|
||||
{
|
||||
@@ -167,6 +167,8 @@ public sealed class AdminLogsEui : BaseEui
|
||||
SendMessage(message);
|
||||
|
||||
_sawmill.Info($"Sent {logs.Count} logs to {Player.Name} in {stopwatch.Elapsed.TotalMilliseconds} ms");
|
||||
|
||||
_adminLogListPool.Return(logs);
|
||||
}
|
||||
|
||||
public override void Closed()
|
||||
|
||||
Reference in New Issue
Block a user