-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #407 from FFXIV-CombatReborn/concurrentdictionaryc…
…rashfix Enhance thread safety and refactor exception handling
- Loading branch information
Showing
5 changed files
with
169 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using Dalamud.Game.ClientState.JobGauge; | ||
using Dalamud.Plugin.Services; | ||
using System; | ||
|
||
namespace RotationSolver.Basic.Data | ||
{ | ||
/// <summary> | ||
/// Manages job gauges and provides thread-safe access to them. | ||
/// </summary> | ||
public class JobGaugeManager | ||
{ | ||
private readonly IJobGauges jobGauges; | ||
private readonly object lockObject = new object(); | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="JobGaugeManager"/> class. | ||
/// </summary> | ||
/// <param name="jobGauges">The job gauges service.</param> | ||
/// <exception cref="ArgumentNullException">Thrown when <paramref name="jobGauges"/> is null.</exception> | ||
public JobGaugeManager(IJobGauges jobGauges) | ||
{ | ||
this.jobGauges = jobGauges ?? throw new ArgumentNullException(nameof(jobGauges)); | ||
} | ||
|
||
/// <summary> | ||
/// Gets the job gauge of the specified type. | ||
/// </summary> | ||
/// <typeparam name="T">The type of the job gauge.</typeparam> | ||
/// <returns>The job gauge of the specified type.</returns> | ||
public T GetJobGauge<T>() where T : JobGaugeBase | ||
{ | ||
lock (lockObject) | ||
{ | ||
return jobGauges.Get<T>(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters