mirror of
https://github.com/cookiengineer/audacity
synced 2025-12-15 00:51:21 +01:00
Manage block files with std::shared_ptr, BlockHash stores weak_ptr
This commit is contained in:
@@ -74,33 +74,6 @@ ODPCMAliasBlockFile::~ODPCMAliasBlockFile()
|
||||
{
|
||||
}
|
||||
|
||||
/// Increases the reference count of this block by one. Only
|
||||
/// DirManager should call this method.
|
||||
/// This method has been overidden to be threadsafe. It is important especially
|
||||
/// if two blockfiles deref at the same time resulting in a double deletion of the file
|
||||
void ODPCMAliasBlockFile::Ref() const
|
||||
{
|
||||
mRefMutex.Lock();
|
||||
BlockFile::Ref();
|
||||
mRefMutex.Unlock();
|
||||
}
|
||||
|
||||
/// 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 ODPCMAliasBlockFile::Deref() const
|
||||
{
|
||||
bool ret;
|
||||
mDerefMutex.Lock();
|
||||
ret = BlockFile::Deref();
|
||||
if(!ret)
|
||||
{
|
||||
//Deref returns true when deleted, in which case we should not be touching instance variables, or ever calling this function again.
|
||||
mDerefMutex.Unlock();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Check to see if we have the file for these calls.
|
||||
|
||||
@@ -143,13 +143,6 @@ protected:
|
||||
sampleFormat format, ArrayOf<char> &cleanup) override;
|
||||
|
||||
private:
|
||||
//Thread-safe versions
|
||||
void Ref() const override;
|
||||
bool Deref() const override;
|
||||
//needed for Ref/Deref access.
|
||||
friend class DirManager;
|
||||
friend class ODComputeSummaryTask;
|
||||
friend class ODDecodeTask;
|
||||
|
||||
ODLock mWriteSummaryMutex;
|
||||
|
||||
@@ -162,11 +155,6 @@ protected:
|
||||
//lock the read data - libsndfile can't handle two reads at once?
|
||||
mutable ODLock mReadDataMutex;
|
||||
|
||||
|
||||
//lock the Ref counting
|
||||
mutable ODLock mDerefMutex;
|
||||
mutable ODLock mRefMutex;
|
||||
|
||||
mutable ODLock mSummaryAvailableMutex;
|
||||
bool mSummaryAvailable;
|
||||
bool mSummaryBeingComputed;
|
||||
|
||||
Reference in New Issue
Block a user