1
0
mirror of https://github.com/cookiengineer/audacity synced 2026-02-07 12:12:23 +01:00

Manage block files with std::shared_ptr, BlockHash stores weak_ptr

This commit is contained in:
Paul Licameli
2016-08-16 10:52:43 -04:00
parent 84ccdca5c3
commit 8b72bd2f92
14 changed files with 51 additions and 230 deletions

View File

@@ -101,7 +101,6 @@ ArrayOf<char> BlockFile::fullSummary;
/// @param samples The number of samples this BlockFile contains.
BlockFile::BlockFile(wxFileNameWrapper &&fileName, sampleCount samples):
mLockCount(0),
mRefCount(1),
mFileName(std::move(fileName)),
mLen(samples),
mSummaryInfo(samples)
@@ -165,28 +164,6 @@ bool BlockFile::IsLocked()
return mLockCount > 0;
}
/// Increases the reference count of this block by one. Only
/// DirManager should call this method.
void BlockFile::Ref() const
{
mRefCount++;
BLOCKFILE_DEBUG_OUTPUT("Ref", mRefCount);
}
/// Decreases the reference count of this block by one. If this
/// causes the count to become zero, deletes the associated disk
/// file and deletes this object
bool BlockFile::Deref() const
{
mRefCount--;
BLOCKFILE_DEBUG_OUTPUT("Deref", mRefCount);
if (mRefCount <= 0) {
delete this;
return true;
} else
return false;
}
/// Get a buffer containing a summary block describing this sample
/// data. This must be called by derived classes when they
/// are constructed, to allow them to construct their summary data,