diff data/model/Dense3DModelPeakCache.h @ 1778:59d9dcfd67c2

Replace the model used for the cache part of the peak-cache model with a simple vector of vectors. Avoids unnecessary locking in a class that is not thread-safe in any case. Also record whether the final column is actually truncated, rather than risk possible backward seeks to re-read it in the case where it simply might be
author Chris Cannam
date Wed, 11 Sep 2019 11:19:27 +0100
parents 6d09d68165a4
children c546429d4c2f
line wrap: on
line diff
--- a/data/model/Dense3DModelPeakCache.h	Tue Sep 10 16:34:47 2019 +0100
+++ b/data/model/Dense3DModelPeakCache.h	Wed Sep 11 11:19:27 2019 +0100
@@ -19,6 +19,15 @@
 #include "DenseThreeDimensionalModel.h"
 #include "EditableDenseThreeDimensionalModel.h"
 
+/**
+ * A DenseThreeDimensionalModel that represents a reduction in the
+ * time dimension of another DenseThreeDimensionalModel. Each column
+ * contains the peak values from a number of consecutive columns in
+ * the source. Each column is populated from the source model when
+ * first requested, and is returned from cache on subsequent requests.
+ *
+ * Dense3DModelPeakCache is not thread-safe.
+ */
 class Dense3DModelPeakCache : public DenseThreeDimensionalModel
 {
     Q_OBJECT
@@ -120,11 +129,13 @@
 
 private:
     ModelId m_source;
-    mutable std::unique_ptr<EditableDenseThreeDimensionalModel> m_cache;
-    mutable std::vector<bool> m_coverage; // must be bool, for space efficiency
-                                          // (vector of bool uses 1-bit elements)
     int m_columnsPerPeak;
 
+    mutable std::vector<std::vector<float>> m_cache;
+    mutable std::vector<bool> m_coverage; // bool for space efficiency
+                                          // (vector of bool is a bitmap)
+    mutable bool m_finalColumnIncomplete;
+
     bool haveColumn(int column) const;
     void fillColumn(int column) const;
 };