[AddonEventManager] Actually Ensure Thread Safety (#1589)

* Actually make AddonEventManager thread safe

* Ensure AddonEventHandlers are also thread safe

Additionally, use Guid instead of strings

* Make DalamudInternalKey readonly

* Properly use ConcurrentDict features

Fixes GUID not working
This commit is contained in:
MidoriKami 2023-12-31 14:30:21 -08:00 committed by GitHub
parent a6b802b577
commit 02b1f6e426
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 43 additions and 58 deletions

View file

@ -19,19 +19,11 @@ internal unsafe class PluginEventController : IDisposable
/// <summary>
/// Initializes a new instance of the <see cref="PluginEventController"/> class.
/// </summary>
/// <param name="pluginId">The Unique ID for this plugin.</param>
public PluginEventController(string pluginId)
public PluginEventController()
{
this.PluginId = pluginId;
this.EventListener = new AddonEventListener(this.PluginEventListHandler);
}
/// <summary>
/// Gets the unique ID for this PluginEventList.
/// </summary>
public string PluginId { get; init; }
private AddonEventListener EventListener { get; init; }
private List<AddonEventEntry> Events { get; } = new();
@ -125,7 +117,7 @@ internal unsafe class PluginEventController : IDisposable
if (this.Events.All(registeredEvent => registeredEvent.ParamKey != i)) return i;
}
throw new OverflowException($"uint.MaxValue number of ParamKeys used for {this.PluginId}");
throw new OverflowException($"uint.MaxValue number of ParamKeys used for this event controller.");
}
/// <summary>