Use new Lock objects

This commit is contained in:
Haselnussbomber 2025-10-24 02:29:43 +02:00
parent 0656bff1f9
commit 6bdc785273
No known key found for this signature in database
GPG key ID: BB905BB49E7295D1
9 changed files with 21 additions and 13 deletions

View file

@ -2,6 +2,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Threading;
using Dalamud.Game.Text;
using Dalamud.Game.Text.SeStringHandling;
@ -57,7 +58,7 @@ internal sealed unsafe class ContextMenu : IInternalDisposableService, IContextM
private Dictionary<ContextMenuType, List<IMenuItem>> MenuItems { get; } = [];
private object MenuItemsLock { get; } = new();
private Lock MenuItemsLock { get; } = new();
private AgentInterface* SelectedAgent { get; set; }

View file

@ -2,6 +2,7 @@ using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading;
using Dalamud.Logging.Internal;
using Dalamud.Memory;
@ -30,7 +31,7 @@ internal class HookManager : IInternalDisposableService
/// <summary>
/// Gets sync root object for hook enabling/disabling.
/// </summary>
internal static object HookEnableSyncRoot { get; } = new();
internal static Lock HookEnableSyncRoot { get; } = new();
/// <summary>
/// Gets a static list of tracked and registered hooks.

View file

@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using Dalamud.Utility;
@ -11,7 +12,7 @@ namespace Dalamud.Interface.ImGuiFileDialog;
/// </summary>
public partial class FileDialog
{
private readonly object filesLock = new();
private readonly Lock filesLock = new();
private readonly DriveListLoader driveListLoader = new();

View file

@ -137,9 +137,9 @@ internal class TexWidget : IDataWindowWidget
conf.QueueSave();
}
var allBlames = this.textureManager.BlameTracker;
lock (allBlames)
lock (this.textureManager.BlameTracker)
{
var allBlames = this.textureManager.BlameTracker;
ImGui.PushID("blames"u8);
var sizeSum = allBlames.Sum(static x => Math.Max(0, x.RawSpecs.EstimatedBytes));
if (ImGui.CollapsingHeader(

View file

@ -1,5 +1,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using Dalamud.Bindings.ImGui;
using Dalamud.Interface.Utility;
@ -35,7 +36,7 @@ internal sealed class DelegateFontHandle : FontHandle
internal sealed class HandleManager : IFontHandleManager
{
private readonly HashSet<DelegateFontHandle> handles = new();
private readonly object syncRoot = new();
private readonly Lock syncRoot = new();
/// <summary>
/// Initializes a new instance of the <see cref="HandleManager"/> class.

View file

@ -1,4 +1,4 @@
// #define VeryVerboseLog
// #define VeryVerboseLog
using System.Collections.Generic;
using System.Diagnostics;
@ -41,7 +41,7 @@ internal sealed partial class FontAtlasFactory
/// <summary>
/// If set, disables concurrent font build operation.
/// </summary>
private static readonly object? NoConcurrentBuildOperationLock = null; // new();
private static readonly Lock? NoConcurrentBuildOperationLock = null; // new();
private static readonly ModuleLog Log = new(nameof(FontAtlasFactory));
@ -254,7 +254,7 @@ internal sealed partial class FontAtlasFactory
private readonly GamePrebakedFontHandle.HandleManager gameFontHandleManager;
private readonly IFontHandleManager[] fontHandleManagers;
private readonly object syncRoot = new();
private readonly Lock syncRoot = new();
private Task<FontAtlasBuiltData?> buildTask = EmptyTask;
private FontAtlasBuiltData? builtData;

View file

@ -4,6 +4,7 @@ using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Reactive.Disposables;
using System.Threading;
using Dalamud.Bindings.ImGui;
using Dalamud.Game.Text;
@ -12,6 +13,7 @@ using Dalamud.Interface.Internal;
using Dalamud.Interface.Textures.TextureWraps;
using Dalamud.Interface.Utility;
using Dalamud.Utility;
using Lumina.Data.Files;
using Vector4 = System.Numerics.Vector4;
@ -103,7 +105,7 @@ internal class GamePrebakedFontHandle : FontHandle
{
private readonly Dictionary<GameFontStyle, int> gameFontsRc = new();
private readonly HashSet<GamePrebakedFontHandle> handles = new();
private readonly object syncRoot = new();
private readonly Lock syncRoot = new();
/// <summary>
/// Initializes a new instance of the <see cref="HandleManager"/> class.

View file

@ -23,7 +23,7 @@ internal abstract class SharedImmediateTexture
private static long instanceCounter;
private readonly object reviveLock = new();
private readonly Lock reviveLock = new();
private readonly List<LocalPlugin> ownerPlugins = new();
private bool resourceReleased;

View file

@ -1,9 +1,11 @@
using System.IO;
using System.IO;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Dalamud.Logging.Internal;
using Dalamud.Utility;
using SQLite;
namespace Dalamud.Storage;
@ -27,7 +29,7 @@ internal class ReliableFileStorage : IInternalDisposableService
{
private static readonly ModuleLog Log = new("VFS");
private readonly object syncRoot = new();
private readonly Lock syncRoot = new();
private SQLiteConnection? db;