Skip to content

Commit

Permalink
Parallel switch + Padding
Browse files Browse the repository at this point in the history
  • Loading branch information
jsboige committed Apr 25, 2024
1 parent 1b85b32 commit 0e5870a
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ public enum CardDocumentFormat
{
AlternateFaceAndBack,
BackFirstOneDocPerBack,
PrintAndPlay
}
PrintAndPlay,
FacesOnly
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ public class CardSetDocumentConfig: DocumentConfig
public string PageSize { get; set; } = "A4";

public string Header { get; set; } = "";



public int Padding { get; set; }
public int NbColumns { get; internal set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ public IBrowser Browser

var funcBrowser = () => Browser;

var parallelOptionsCardset = new ParallelOptions { MaxDegreeOfParallelism = Config.MaxDegreeOfParallelismCardpen };
var parallelOptionsCardset = new ParallelOptions { MaxDegreeOfParallelism = Config.EnableParallelism? Config.MaxDegreeOfParallelismCardpen : 1 };
await Parallel.ForEachAsync(targetCardSets, parallelOptionsCardset, async (configCardSet, token) =>
{
var targetLanguages = AssetConverterConfig.LocalizationConfig.BuildLanguageList(configCardSet.Translations);

var parallelOptionsCardsetLanguage = new ParallelOptions { MaxDegreeOfParallelism = Config.MaxDegreeOfParallelismCardpenTranslations };
var parallelOptionsCardsetLanguage = new ParallelOptions { MaxDegreeOfParallelism = Config.EnableParallelism? Config.MaxDegreeOfParallelismCardpenTranslations : 1 };
await Parallel.ForEachAsync(targetLanguages, parallelOptionsCardsetLanguage, async (currentLanguage, newToken) =>
{
await ProcessLocalizedHarvest(configCardSet, currentLanguage, harvestDictionary, funcBrowser);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class ImageFileGenerator
Logger.LogExplanations("In its second stage, Argumentum creates individual image files from the harvested collections. Images are processed with Magick.Net according to configuration parameters. This is the more taxing stage, the degree of parallelism of which can also be configured.");

var toReturn = new ConcurrentDictionary<(CardSetDocumentConfig document, string language), List<CardImages>>();
var parallelOptionsDocuments = new ParallelOptions { MaxDegreeOfParallelism = Config.MaxDegreeOfParallelismImages };
var parallelOptionsDocuments = new ParallelOptions { MaxDegreeOfParallelism = Config.EnableParallelism? Config.MaxDegreeOfParallelismImages : 1 };

Parallel.ForEach(Config.CardSetDocuments.Where(d => d.Enabled), parallelOptionsDocuments, configDocument =>
//foreach (var configDocument in Config.Documents.Where(d => d.Enabled))
Expand All @@ -41,7 +41,7 @@ public class ImageFileGenerator
{
targetLanguages.AddRange(configDocument.Translations.Select(t => t.targetLanguage));
}
var parallelOptionsDocumentsTranslations = new ParallelOptions { MaxDegreeOfParallelism = Config.MaxDegreeOfParallelismImageTranslations };
var parallelOptionsDocumentsTranslations = new ParallelOptions { MaxDegreeOfParallelism = Config.EnableParallelism ? Config.MaxDegreeOfParallelismImageTranslations : 1 };
Parallel.ForEach(targetLanguages, parallelOptionsDocumentsTranslations, currentLanguage =>
//foreach (var currentLanguage in targetLanguages)
{
Expand Down

0 comments on commit 0e5870a

Please sign in to comment.