Reduce custom code

Signed-off-by: falkTX <falktx@falktx.com>
This commit is contained in:
falkTX 2022-12-30 16:02:53 +00:00
parent ebaa70b05a
commit 476bae222f
No known key found for this signature in database
GPG key ID: CDBAA37ABC74FBA0
3 changed files with 7 additions and 355 deletions

View file

@ -3,7 +3,7 @@
This file is part of the Water library.
Copyright (c) 2016 ROLI Ltd.
Copyright (C) 2017-2019 Filipe Coelho <falktx@falktx.com>
Copyright (C) 2017-2022 Filipe Coelho <falktx@falktx.com>
Permission is granted to use this software under the terms of the ISC license
http://www.isc.org/downloads/software-support-policy/isc-license/
@ -27,7 +27,7 @@
#define WATER_SHAREDRESOURCEPOINTER_HPP_INCLUDED
#include "ReferenceCountedObject.hpp"
#include "SpinLock.hpp"
#include "extra/Mutex.hpp"
#include "extra/ScopedPointer.hpp"
START_NAMESPACE_DISTRHO
@ -127,7 +127,7 @@ public:
~SharedResourcePointer()
{
SharedObjectHolder& holder = getSharedObjectHolder();
const SpinLock::ScopedLockType sl (holder.lock);
const MutexLocker cml (holder.lock);
if (--(holder.refCount) == 0)
holder.sharedInstance = nullptr;
@ -150,7 +150,7 @@ public:
private:
struct SharedObjectHolder : public ReferenceCountedObject
{
SpinLock lock;
Mutex lock;
ScopedPointer<SharedObjectType> sharedInstance;
int refCount;
};
@ -166,7 +166,7 @@ private:
void initialise()
{
SharedObjectHolder& holder = getSharedObjectHolder();
const SpinLock::ScopedLockType sl (holder.lock);
const MutexLocker cml (holder.lock);
if (++(holder.refCount) == 1)
holder.sharedInstance = new SharedObjectType();
@ -178,7 +178,7 @@ private:
void initialise_variant(const T* const variant)
{
SharedObjectHolder& holder = getSharedObjectHolder();
const SpinLock::ScopedLockType sl (holder.lock);
const MutexLocker cml (holder.lock);
if (++(holder.refCount) == 1)
holder.sharedInstance = new SharedObjectType(variant);
@ -190,7 +190,7 @@ private:
void initialise_variant2(const T1* const v1, const T2* const v2)
{
SharedObjectHolder& holder = getSharedObjectHolder();
const SpinLock::ScopedLockType sl (holder.lock);
const MutexLocker cml (holder.lock);
if (++(holder.refCount) == 1)
holder.sharedInstance = new SharedObjectType(v1, v2);