1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-16 16:10:06 +02:00

Make const overload of ClientData::Site::ForEach usable

This commit is contained in:
Paul Licameli 2019-07-09 16:01:43 -04:00
parent 36cb2918be
commit d8b3d16554
2 changed files with 9 additions and 4 deletions

View File

@ -416,7 +416,12 @@ private:
{
return Locked< DataContainer >{ mData };
}
Locked<const DataContainer> GetData() const
{
return Locked< const DataContainer >{ mData };
}
static void EnsureIndex( Locked<DataContainer> &data, size_t index )
{
if (data.mObject.size() <= index)

View File

@ -57,19 +57,19 @@ template< typename Object > struct Lockable< Object, NoLocking >
: Object {
// implement trivial non-locking policy
struct Lock{};
Lock lock() { return {}; }
Lock lock() const { return {}; }
};
template< typename Object > struct Lockable< Object, NonrecursiveLocking >
: Object, std::mutex {
// implement real locking
using Lock = std::unique_lock< std::mutex >;
Lock lock() { return Lock{ *this }; }
Lock lock() const { return Lock{ *this }; }
};
template< typename Object > struct Lockable< Object, RecursiveLocking >
: Object, std::recursive_mutex {
// implement real locking
using Lock = std::unique_lock< std::recursive_mutex >;
Lock lock() { return Lock{ *this }; }
Lock lock() const { return Lock{ *this }; }
};
// Pairing of a reference to a Lockable and a lock on it