Skip to content

Commit

Permalink
Manager: Fix potential race condition in game data gathering
Browse files Browse the repository at this point in the history
  • Loading branch information
Sejsel committed Jul 25, 2023
1 parent 14da9f3 commit 1fa25d5
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions ArcdpsLogManager/Sections/GameDataGathering.cs
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,8 @@ private void GatherData(LogList logList, ProgressBar progressBar, Label progress
return Task.Run(() =>
{
// TODO: Change List into some kind of concurrent bag
var species = new ConcurrentDictionary<int, ConcurrentDictionary<SpeciesData, List<LogData>>>();
var skills = new ConcurrentDictionary<uint, ConcurrentDictionary<SkillData, List<LogData>>>();
var species = new ConcurrentDictionary<int, ConcurrentDictionary<SpeciesData, ConcurrentBag<LogData>>>();
var skills = new ConcurrentDictionary<uint, ConcurrentDictionary<SkillData, ConcurrentBag<LogData>>>();
int done = 0;
int failed = 0;
Expand Down Expand Up @@ -405,9 +405,9 @@ private void GatherData(LogList logList, ProgressBar progressBar, Label progress
if (id == 0) continue;
var speciesData = new SpeciesData(id, name);
var dictForSpecies = species.GetOrAdd(id, new ConcurrentDictionary<SpeciesData, List<LogData>>());
var dictForSpecies = species.GetOrAdd(id, new ConcurrentDictionary<SpeciesData, ConcurrentBag<LogData>>());
var listForSpeciesData = dictForSpecies.GetOrAdd(speciesData, new List<LogData>());
var listForSpeciesData = dictForSpecies.GetOrAdd(speciesData, new ConcurrentBag<LogData>());
listForSpeciesData.Add(log);
}
Expand All @@ -426,9 +426,9 @@ private void GatherData(LogList logList, ProgressBar progressBar, Label progress
if (id == 0) continue;
var skillData = new SkillData(id, name, skillType);
var dictForSkill = skills.GetOrAdd(id, new ConcurrentDictionary<SkillData, List<LogData>>());
var dictForSkill = skills.GetOrAdd(id, new ConcurrentDictionary<SkillData, ConcurrentBag<LogData>>());
var listForSkillData = dictForSkill.GetOrAdd(skillData, new List<LogData>());
var listForSkillData = dictForSkill.GetOrAdd(skillData, new ConcurrentBag<LogData>());
listForSkillData.Add(log);
}
Expand Down

0 comments on commit 1fa25d5

Please sign in to comment.