15#ifndef GDALABSTRACTBANDBLOCKCACHE_H_INCLUDED
16#define GDALABSTRACTBANDBLOCKCACHE_H_INCLUDED
21typedef struct _CPLCond CPLCond;
22typedef struct _CPLLock CPLLock;
23typedef struct _CPLMutex CPLMutex;
37class GDALAbstractBandBlockCache
40 CPLLock *hSpinLock =
nullptr;
41 GDALRasterBlock *psListBlocksToFree =
nullptr;
44 CPLCond *hCond =
nullptr;
45 CPLMutex *hCondMutex =
nullptr;
46 volatile int nKeepAliveCounter = 0;
48 volatile int m_nDirtyBlocks = 0;
53 explicit GDALAbstractBandBlockCache(GDALRasterBand *poBand);
55 GDALRasterBand *poBand;
57 int m_nInitialDirtyBlocksInFlushCache = 0;
59 size_t m_nWriteDirtyBlocksDisabled = 0;
61 void FreeDanglingBlocks();
62 void UnreferenceBlockBase();
64 void StartDirtyBlockFlushingLog();
65 void UpdateDirtyBlockFlushingLog();
66 void EndDirtyBlockFlushingLog();
69 virtual ~GDALAbstractBandBlockCache();
71 GDALRasterBlock *CreateBlock(
int nXBlockOff,
int nYBlockOff);
72 void AddBlockToFreeList(GDALRasterBlock *poBlock);
73 void IncDirtyBlocks(
int nInc);
74 void WaitCompletionPendingTasks();
76 void EnableDirtyBlockWriting()
78 --m_nWriteDirtyBlocksDisabled;
81 void DisableDirtyBlockWriting()
83 ++m_nWriteDirtyBlocksDisabled;
86 bool HasDirtyBlocks()
const
88 return m_nDirtyBlocks > 0;
91 virtual bool Init() = 0;
92 virtual bool IsInitOK() = 0;
93 virtual CPLErr FlushCache() = 0;
94 virtual CPLErr AdoptBlock(GDALRasterBlock *poBlock) = 0;
95 virtual GDALRasterBlock *TryGetLockedBlockRef(
int nXBlockOff,
97 virtual CPLErr UnreferenceBlock(GDALRasterBlock *poBlock) = 0;
98 virtual CPLErr FlushBlock(
int nXBlockOff,
int nYBlockOff,
99 int bWriteDirtyBlock) = 0;
102GDALAbstractBandBlockCache *
104GDALAbstractBandBlockCache *
A single raster band (or channel).
Definition gdal_rasterband.h:105
A single raster block in the block cache.
Definition gdal_rasterblock.h:33
CPL error handling services.
CPLErr
Error category.
Definition cpl_error.h:37
Core portability definitions for CPL.
#define CPL_DISALLOW_COPY_ASSIGN(ClassName)
Helper to remove the copy and assignment constructors so that the compiler will not generate the defa...
Definition cpl_port.h:936