Skip to content

Commit

Permalink
Publicly readable FFT cache pool size
Browse files Browse the repository at this point in the history
  • Loading branch information
VoidXH committed Oct 21, 2023
1 parent 5d58e6b commit 13b3ee2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions Cavern/Utilities/FFTCachePool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,27 @@ namespace Cavern.Utilities {
/// </summary>
public class FFTCachePool : IDisposable {
/// <summary>
/// Caches not currently leased.
/// Size of the used FFTs.
/// </summary>
readonly Stack<FFTCache> caches = new Stack<FFTCache>();
public int Size { get; private set; }

/// <summary>
/// Size of the used FFTs.
/// Caches not currently leased.
/// </summary>
readonly int size;
readonly Stack<FFTCache> caches = new Stack<FFTCache>();

/// <summary>
/// Create an <see cref="FFTCache"/> pool for this FFT size.
/// </summary>
public FFTCachePool(int size) => this.size = size;
public FFTCachePool(int size) => Size = size;

/// <summary>
/// Get an <see cref="FFTCache"/> to work with.
/// </summary>
public FFTCache Lease() {
lock (this) {
if (caches.Count == 0) {
return new ThreadSafeFFTCache(size);
return new ThreadSafeFFTCache(Size);
} else {
return caches.Pop();
}
Expand Down
2 changes: 1 addition & 1 deletion Cavern/Utilities/Measurements.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ public static void InPlaceIFFTUnscaled(this Complex[] samples, FFTCache cache) {
public static void MinimumPhaseSpectrum(Complex[] response, FFTCache cache) {
bool customCache = false;
if (cache == null) {
cache = new FFTCache(response.Length);
cache = new ThreadSafeFFTCache(response.Length);
customCache = true;
}
int halfLength = response.Length / 2;
Expand Down

0 comments on commit 13b3ee2

Please sign in to comment.