mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-20 11:05:54 +00:00
Rename to SharedObject
This commit is contained in:
@@ -144,7 +144,7 @@
|
||||
<ClInclude Include="..\..\modules\beast_core\memory\beast_MemoryAlignment.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\memory\beast_MemoryBlock.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\memory\beast_OptionalScopedPointer.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\memory\beast_ReferenceCountedObject.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\memory\beast_SharedObject.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\memory\beast_ScopedPointer.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\memory\beast_SharedSingleton.h" />
|
||||
<ClInclude Include="..\..\modules\beast_core\memory\beast_StaticObject.h" />
|
||||
|
||||
@@ -229,9 +229,6 @@
|
||||
<ClInclude Include="..\..\modules\beast_core\memory\beast_OptionalScopedPointer.h">
|
||||
<Filter>beast_core\memory</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\modules\beast_core\memory\beast_ReferenceCountedObject.h">
|
||||
<Filter>beast_core\memory</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\modules\beast_core\memory\beast_ScopedPointer.h">
|
||||
<Filter>beast_core\memory</Filter>
|
||||
</ClInclude>
|
||||
@@ -608,6 +605,9 @@
|
||||
<ClInclude Include="..\..\modules\beast_basics\events\beast_DeadlineTimer.h">
|
||||
<Filter>beast_basics\events</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\modules\beast_core\memory\beast_SharedObject.h">
|
||||
<Filter>beast_core\memory</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\modules\beast_core\beast_core.cpp">
|
||||
|
||||
@@ -112,7 +112,7 @@ private:
|
||||
class Manager;
|
||||
|
||||
Listener* const m_listener;
|
||||
ReferenceCountedObjectPtr <Manager> m_manager;
|
||||
SharedObjectPtr <Manager> m_manager;
|
||||
bool m_isActive;
|
||||
Time m_notificationTime;
|
||||
double m_secondsRecurring; // non zero if recurring
|
||||
|
||||
@@ -48,7 +48,7 @@ protected:
|
||||
|
||||
private:
|
||||
class TimerSingleton;
|
||||
typedef ReferenceCountedObjectPtr <TimerSingleton> TimerPtr;
|
||||
typedef SharedObjectPtr <TimerSingleton> TimerPtr;
|
||||
|
||||
struct Elem : List <Elem>::Node
|
||||
{
|
||||
|
||||
@@ -103,10 +103,10 @@ private:
|
||||
// Each Entry holds a group and the current Call (which can be updated).
|
||||
//
|
||||
struct ListenersBase::Proxy::Entry : Entries::Node,
|
||||
ReferenceCountedObject,
|
||||
SharedObject,
|
||||
AllocatedBy <AllocatorType>
|
||||
{
|
||||
typedef ReferenceCountedObjectPtr <Entry> Ptr;
|
||||
typedef SharedObjectPtr <Entry> Ptr;
|
||||
|
||||
explicit Entry (Group* g)
|
||||
: group (g)
|
||||
|
||||
@@ -214,11 +214,11 @@ public:
|
||||
|
||||
typedef GlobalFifoFreeStore <ListenersBase> CallAllocatorType;
|
||||
|
||||
class Call : public ReferenceCountedObject,
|
||||
class Call : public SharedObject,
|
||||
public AllocatedBy <CallAllocatorType>
|
||||
{
|
||||
public:
|
||||
typedef ReferenceCountedObjectPtr <Call> Ptr;
|
||||
typedef SharedObjectPtr <Call> Ptr;
|
||||
virtual void operator () (void* const listener) = 0;
|
||||
};
|
||||
|
||||
@@ -238,11 +238,11 @@ private:
|
||||
// Maintains a list of listeners registered on the same CallQueue
|
||||
//
|
||||
class Group : public Groups::Node,
|
||||
public ReferenceCountedObject,
|
||||
public SharedObject,
|
||||
public AllocatedBy <AllocatorType>
|
||||
{
|
||||
public:
|
||||
typedef ReferenceCountedObjectPtr <Group> Ptr;
|
||||
typedef SharedObjectPtr <Group> Ptr;
|
||||
|
||||
explicit Group (CallQueue& callQueue);
|
||||
~Group ();
|
||||
|
||||
@@ -20,98 +20,97 @@
|
||||
#ifndef BEAST_SHAREDDATA_H_INCLUDED
|
||||
#define BEAST_SHAREDDATA_H_INCLUDED
|
||||
|
||||
/*============================================================================*/
|
||||
/**
|
||||
Structured access to a shared state.
|
||||
/** Structured access to a shared state.
|
||||
|
||||
This template wraps an object containing members representing state
|
||||
information shared between multiple threads of execution, where any thread
|
||||
may need to read or write as needed. Synchronized access to the concurrent
|
||||
state is enforced at compile time through strongly typed accessor classes.
|
||||
This interface design facilitates source code pattern matching to find all
|
||||
areas where a concurrent state is accessed.
|
||||
This template wraps an object containing members representing state
|
||||
information shared between multiple threads of execution, where any thread
|
||||
may need to read or write as needed. Synchronized access to the concurrent
|
||||
state is enforced at compile time through strongly typed accessor classes.
|
||||
This interface design facilitates source code pattern matching to find all
|
||||
areas where a concurrent state is accessed.
|
||||
|
||||
There are three types of access:
|
||||
There are three types of access:
|
||||
|
||||
- ReadAccess
|
||||
- ReadAccess
|
||||
|
||||
Allows read access to the underlying object as `const`. ReadAccess may be
|
||||
granted to one or more threads simultaneously. If one or more threads have
|
||||
ReadAccess, requests to obtain WriteAccess are blocked.
|
||||
Allows read access to the underlying object as `const`. ReadAccess may
|
||||
be granted to one or more threads simultaneously. If one or more
|
||||
threads have ReadAccess, requests to obtain WriteAccess are blocked.
|
||||
|
||||
- WriteAccess
|
||||
- WriteAccess
|
||||
|
||||
Allows exclusive read/write access the underlying object. A WriteAccess
|
||||
request blocks until all existing ReadAccess and WriteAccess requests are
|
||||
released. While a WriteAccess exists, requests for ReadAccess will block.
|
||||
Allows exclusive read/write access the underlying object. A WriteAccess
|
||||
request blocks until all existing ReadAccess and WriteAccess requests
|
||||
are released. While a WriteAccess exists, requests for ReadAccess
|
||||
will block.
|
||||
|
||||
- UnlockedAccess
|
||||
- UnlockedAccess
|
||||
|
||||
Allows read access to the underlying object without using the lock. This
|
||||
can be helpful when designing concurrent structures through composition.
|
||||
It also makes it easier to search for places in code which use unlocked
|
||||
access.
|
||||
Allows read access to the underlying object without using the lock.
|
||||
This can be helpful when designing concurrent structures through
|
||||
composition. It also makes it easier to search for places in code
|
||||
which use unlocked access.
|
||||
|
||||
This code example demonstrates various forms of access to a SharedData:
|
||||
This code example demonstrates various forms of access to a SharedData:
|
||||
|
||||
@code
|
||||
@code
|
||||
|
||||
struct SharedData
|
||||
{
|
||||
int value1;
|
||||
String value2;
|
||||
};
|
||||
|
||||
typedef SharedData <SharedData> SharedState;
|
||||
|
||||
SharedState sharedState;
|
||||
|
||||
void readExample ()
|
||||
{
|
||||
SharedState::ReadAccess state (sharedState);
|
||||
|
||||
print (state->value1); // read access
|
||||
print (state->value2); // read access
|
||||
|
||||
state->value1 = 42; // write disallowed: compile error
|
||||
}
|
||||
|
||||
void writeExample ()
|
||||
{
|
||||
SharedState::WriteAccess state (sharedState);
|
||||
|
||||
state->value2 = "Label"; // write access
|
||||
}
|
||||
|
||||
@endcode
|
||||
|
||||
Forwarding constructors with up to eight parameters are provided. This lets
|
||||
you write constructors into the underlying data object. For example:
|
||||
|
||||
@code
|
||||
|
||||
struct SharedData
|
||||
{
|
||||
explicit SharedData (int numSlots)
|
||||
struct SharedData
|
||||
{
|
||||
m_array.reserve (numSlots);
|
||||
int value1;
|
||||
String value2;
|
||||
};
|
||||
|
||||
typedef SharedData <SharedData> SharedState;
|
||||
|
||||
SharedState sharedState;
|
||||
|
||||
void readExample ()
|
||||
{
|
||||
SharedState::ReadAccess state (sharedState);
|
||||
|
||||
print (state->value1); // read access
|
||||
print (state->value2); // read access
|
||||
|
||||
state->value1 = 42; // write disallowed: compile error
|
||||
}
|
||||
|
||||
std::vector <AudioSampleBuffer*> m_array;
|
||||
};
|
||||
void writeExample ()
|
||||
{
|
||||
SharedState::WriteAccess state (sharedState);
|
||||
|
||||
// Construct SharedData with one parameter
|
||||
SharedData <SharedData> sharedState (16);
|
||||
state->value2 = "Label"; // write access
|
||||
}
|
||||
|
||||
@endcode
|
||||
@endcode
|
||||
|
||||
@param Object The type of object to encapsulate.
|
||||
Forwarding constructors with up to eight parameters are provided. This lets
|
||||
you write constructors into the underlying data object. For example:
|
||||
|
||||
@warning Recursive calls are not supported. It is generally not possible for
|
||||
a thread of execution to acquire write access while it already has
|
||||
read access. Such an attempt will result in undefined behavior. Calling into
|
||||
unknown code while holding a lock can cause deadlock. See
|
||||
@ref CallQueue::queue().
|
||||
@code
|
||||
|
||||
struct SharedData
|
||||
{
|
||||
explicit SharedData (int numSlots)
|
||||
{
|
||||
m_array.reserve (numSlots);
|
||||
}
|
||||
|
||||
std::vector <AudioSampleBuffer*> m_array;
|
||||
};
|
||||
|
||||
// Construct SharedData with one parameter
|
||||
SharedData <SharedData> sharedState (16);
|
||||
|
||||
@endcode
|
||||
|
||||
@param Object The type of object to encapsulate.
|
||||
|
||||
@warning Recursive calls are not supported. It is generally not possible for
|
||||
a thread of execution to acquire write access while it already has
|
||||
read access. Such an attempt will result in undefined behavior.
|
||||
Calling into unknown code while holding a lock can cause deadlock.
|
||||
See @ref CallQueue::queue().
|
||||
*/
|
||||
template <class Object>
|
||||
class SharedData : Uncopyable
|
||||
|
||||
@@ -255,7 +255,7 @@ namespace beast
|
||||
#include "memory/beast_Memory.h"
|
||||
#include "memory/beast_MemoryBlock.h"
|
||||
#include "memory/beast_OptionalScopedPointer.h"
|
||||
#include "memory/beast_ReferenceCountedObject.h"
|
||||
#include "memory/beast_SharedObject.h"
|
||||
#include "memory/beast_ScopedPointer.h"
|
||||
#include "threads/beast_SpinLock.h"
|
||||
#include "memory/beast_SharedSingleton.h"
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#define BEAST_DYNAMICOBJECT_BEASTHEADER
|
||||
|
||||
#include "beast_NamedValueSet.h"
|
||||
#include "../memory/beast_ReferenceCountedObject.h"
|
||||
#include "../memory/beast_SharedObject.h"
|
||||
|
||||
|
||||
//==============================================================================
|
||||
@@ -40,7 +40,7 @@
|
||||
methods.
|
||||
*/
|
||||
class BEAST_API DynamicObject
|
||||
: public ReferenceCountedObject
|
||||
: public SharedObject
|
||||
, LeakChecked <DynamicObject>
|
||||
{
|
||||
public:
|
||||
@@ -50,7 +50,7 @@ public:
|
||||
/** Destructor. */
|
||||
virtual ~DynamicObject();
|
||||
|
||||
typedef ReferenceCountedObjectPtr<DynamicObject> Ptr;
|
||||
typedef SharedObjectPtr<DynamicObject> Ptr;
|
||||
|
||||
//==============================================================================
|
||||
/** Returns true if the object has a property with this name.
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#ifndef BEAST_REFERENCECOUNTEDARRAY_BEASTHEADER
|
||||
#define BEAST_REFERENCECOUNTEDARRAY_BEASTHEADER
|
||||
|
||||
#include "../memory/beast_ReferenceCountedObject.h"
|
||||
#include "../memory/beast_SharedObject.h"
|
||||
#include "beast_ArrayAllocationBase.h"
|
||||
#include "beast_ElementComparator.h"
|
||||
#include "../threads/beast_CriticalSection.h"
|
||||
@@ -32,9 +32,9 @@
|
||||
|
||||
//==============================================================================
|
||||
/**
|
||||
Holds a list of objects derived from ReferenceCountedObject.
|
||||
Holds a list of objects derived from SharedObject.
|
||||
|
||||
A ReferenceCountedArray holds objects derived from ReferenceCountedObject,
|
||||
A ReferenceCountedArray holds objects derived from SharedObject,
|
||||
and takes care of incrementing and decrementing their ref counts when they
|
||||
are added and removed from the array.
|
||||
|
||||
@@ -47,11 +47,11 @@ template <class ObjectClass, class TypeOfCriticalSectionToUse = DummyCriticalSec
|
||||
class ReferenceCountedArray
|
||||
{
|
||||
public:
|
||||
typedef ReferenceCountedObjectPtr<ObjectClass> ObjectClassPtr;
|
||||
typedef SharedObjectPtr<ObjectClass> ObjectClassPtr;
|
||||
|
||||
//==============================================================================
|
||||
/** Creates an empty array.
|
||||
@see ReferenceCountedObject, Array, OwnedArray
|
||||
@see SharedObject, Array, OwnedArray
|
||||
*/
|
||||
ReferenceCountedArray() noexcept
|
||||
: numUsed (0)
|
||||
|
||||
@@ -156,10 +156,10 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
class Data : public ReferenceCountedObject
|
||||
class Data : public SharedObject
|
||||
{
|
||||
public:
|
||||
typedef ReferenceCountedObjectPtr <Data> Ptr;
|
||||
typedef SharedObjectPtr <Data> Ptr;
|
||||
|
||||
explicit Data (int numEntries)
|
||||
: m_numEntries (numEntries)
|
||||
@@ -200,7 +200,7 @@ private:
|
||||
{
|
||||
}
|
||||
|
||||
ReferenceCountedObjectPtr <Data> m_data;
|
||||
SharedObjectPtr <Data> m_data;
|
||||
};
|
||||
|
||||
template <class ElementType>
|
||||
|
||||
@@ -45,7 +45,7 @@ public:
|
||||
virtual double toDouble (const ValueUnion&) const noexcept { return 0; }
|
||||
virtual String toString (const ValueUnion&) const { return String::empty; }
|
||||
virtual bool toBool (const ValueUnion&) const noexcept { return false; }
|
||||
virtual ReferenceCountedObject* toObject (const ValueUnion&) const noexcept { return nullptr; }
|
||||
virtual SharedObject* toObject (const ValueUnion&) const noexcept { return nullptr; }
|
||||
virtual Array<var>* toArray (const ValueUnion&) const noexcept { return nullptr; }
|
||||
virtual MemoryBlock* toBinary (const ValueUnion&) const noexcept { return nullptr; }
|
||||
|
||||
@@ -243,7 +243,7 @@ public:
|
||||
|
||||
String toString (const ValueUnion& data) const { return "Object 0x" + String::toHexString ((int) (pointer_sized_int) data.objectValue); }
|
||||
bool toBool (const ValueUnion& data) const noexcept { return data.objectValue != 0; }
|
||||
ReferenceCountedObject* toObject (const ValueUnion& data) const noexcept { return data.objectValue; }
|
||||
SharedObject* toObject (const ValueUnion& data) const noexcept { return data.objectValue; }
|
||||
bool isObject() const noexcept { return true; }
|
||||
|
||||
bool equals (const ValueUnion& data, const ValueUnion& otherData, const VariantType& otherType) const noexcept
|
||||
@@ -388,7 +388,7 @@ var::var (const wchar_t* const v) : type (&VariantType_String::instance) { n
|
||||
var::var (const void* v, size_t sz) : type (&VariantType_Binary::instance) { value.binaryValue = new MemoryBlock (v, sz); }
|
||||
var::var (const MemoryBlock& v) : type (&VariantType_Binary::instance) { value.binaryValue = new MemoryBlock (v); }
|
||||
|
||||
var::var (ReferenceCountedObject* const object) : type (&VariantType_Object::instance)
|
||||
var::var (SharedObject* const object) : type (&VariantType_Object::instance)
|
||||
{
|
||||
value.objectValue = object;
|
||||
|
||||
@@ -416,7 +416,7 @@ var::operator float() const noexcept { return (float) type->t
|
||||
var::operator double() const noexcept { return type->toDouble (value); }
|
||||
String var::toString() const { return type->toString (value); }
|
||||
var::operator String() const { return type->toString (value); }
|
||||
ReferenceCountedObject* var::getObject() const noexcept { return type->toObject (value); }
|
||||
SharedObject* var::getObject() const noexcept { return type->toObject (value); }
|
||||
Array<var>* var::getArray() const noexcept { return type->toArray (value); }
|
||||
MemoryBlock* var::getBinaryData() const noexcept { return type->toBinary (value); }
|
||||
DynamicObject* var::getDynamicObject() const noexcept { return dynamic_cast <DynamicObject*> (getObject()); }
|
||||
@@ -437,7 +437,7 @@ var& var::operator= (const char* const v) { type->cleanUp (value); type =
|
||||
var& var::operator= (const wchar_t* const v) { type->cleanUp (value); type = &VariantType_String::instance; new (value.stringValue) String (v); return *this; }
|
||||
var& var::operator= (const String& v) { type->cleanUp (value); type = &VariantType_String::instance; new (value.stringValue) String (v); return *this; }
|
||||
var& var::operator= (const Array<var>& v) { var v2 (v); swapWith (v2); return *this; }
|
||||
var& var::operator= (ReferenceCountedObject* v) { var v2 (v); swapWith (v2); return *this; }
|
||||
var& var::operator= (SharedObject* v) { var v2 (v); swapWith (v2); return *this; }
|
||||
var& var::operator= (MethodFunction v) { var v2 (v); swapWith (v2); return *this; }
|
||||
|
||||
#if BEAST_COMPILER_SUPPORTS_MOVE_SEMANTICS
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#include "../containers/beast_Array.h"
|
||||
|
||||
#ifndef DOXYGEN
|
||||
class ReferenceCountedObject;
|
||||
class SharedObject;
|
||||
class DynamicObject;
|
||||
#endif
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
A variant class, that can be used to hold a range of primitive values.
|
||||
|
||||
A var object can hold a range of simple primitive values, strings, or
|
||||
any kind of ReferenceCountedObject. The var class is intended to act like
|
||||
any kind of SharedObject. The var class is intended to act like
|
||||
the kind of values used in dynamic scripting languages.
|
||||
|
||||
You can save/load var objects either in a small, proprietary binary format
|
||||
@@ -73,7 +73,7 @@ public:
|
||||
var (const wchar_t* value);
|
||||
var (const String& value);
|
||||
var (const Array<var>& value);
|
||||
var (ReferenceCountedObject* object);
|
||||
var (SharedObject* object);
|
||||
var (MethodFunction method) noexcept;
|
||||
var (const void* binaryData, size_t dataSize);
|
||||
var (const MemoryBlock& binaryData);
|
||||
@@ -87,7 +87,7 @@ public:
|
||||
var& operator= (const wchar_t* value);
|
||||
var& operator= (const String& value);
|
||||
var& operator= (const Array<var>& value);
|
||||
var& operator= (ReferenceCountedObject* object);
|
||||
var& operator= (SharedObject* object);
|
||||
var& operator= (MethodFunction method);
|
||||
|
||||
#if BEAST_COMPILER_SUPPORTS_MOVE_SEMANTICS
|
||||
@@ -125,7 +125,7 @@ public:
|
||||
*/
|
||||
MemoryBlock* getBinaryData() const noexcept;
|
||||
|
||||
ReferenceCountedObject* getObject() const noexcept;
|
||||
SharedObject* getObject() const noexcept;
|
||||
DynamicObject* getDynamicObject() const noexcept;
|
||||
|
||||
//==============================================================================
|
||||
@@ -275,7 +275,7 @@ private:
|
||||
bool boolValue;
|
||||
double doubleValue;
|
||||
char stringValue [sizeof (String)];
|
||||
ReferenceCountedObject* objectValue;
|
||||
SharedObject* objectValue;
|
||||
Array<var>* arrayValue;
|
||||
MemoryBlock* binaryValue;
|
||||
MethodFunction methodValue;
|
||||
|
||||
@@ -78,7 +78,7 @@ void LeakCheckedBase::CounterBase::checkForLeaks ()
|
||||
|
||||
If you're leaking, it's probably because you're using old-fashioned,
|
||||
non-RAII techniques for your object management. Tut, tut. Always,
|
||||
always use ScopedPointers, OwnedArrays, ReferenceCountedObjects,
|
||||
always use ScopedPointers, OwnedArrays, SharedObjects,
|
||||
etc, and avoid the 'delete' operator at all costs!
|
||||
*/
|
||||
DBG ("Leaked objects: " << count << " of " << getClassName ());
|
||||
@@ -104,7 +104,7 @@ void LeakCheckedBase::reportDanglingPointer (char const* objectName)
|
||||
Most errors like this are caused by using old-fashioned,
|
||||
non-RAII techniques for your object management. Tut, tut.
|
||||
Always, always use ScopedPointers, OwnedArrays,
|
||||
ReferenceCountedObjects, etc, and avoid the 'delete' operator
|
||||
SharedObjects, etc, and avoid the 'delete' operator
|
||||
at all costs!
|
||||
*/
|
||||
DBG ("Dangling pointer deletion: " << objectName);
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
//==============================================================================
|
||||
|
||||
class Expression::Term
|
||||
: public SingleThreadedReferenceCountedObject
|
||||
: public SingleThreadedSharedObject
|
||||
{
|
||||
public:
|
||||
Term() {}
|
||||
@@ -30,20 +30,20 @@ public:
|
||||
|
||||
virtual Type getType() const noexcept = 0;
|
||||
virtual Term* clone() const = 0;
|
||||
virtual ReferenceCountedObjectPtr<Term> resolve (const Scope&, int recursionDepth) = 0;
|
||||
virtual SharedObjectPtr<Term> resolve (const Scope&, int recursionDepth) = 0;
|
||||
virtual String toString() const = 0;
|
||||
virtual double toDouble() const { return 0; }
|
||||
virtual int getInputIndexFor (const Term*) const { return -1; }
|
||||
virtual int getOperatorPrecedence() const { return 0; }
|
||||
virtual int getNumInputs() const { return 0; }
|
||||
virtual Term* getInput (int) const { return nullptr; }
|
||||
virtual ReferenceCountedObjectPtr<Term> negated();
|
||||
virtual SharedObjectPtr<Term> negated();
|
||||
|
||||
virtual ReferenceCountedObjectPtr<Term> createTermToEvaluateInput (const Scope&, const Term* /*inputTerm*/,
|
||||
virtual SharedObjectPtr<Term> createTermToEvaluateInput (const Scope&, const Term* /*inputTerm*/,
|
||||
double /*overallTarget*/, Term* /*topLevelTerm*/) const
|
||||
{
|
||||
bassertfalse;
|
||||
return ReferenceCountedObjectPtr<Term>();
|
||||
return SharedObjectPtr<Term>();
|
||||
}
|
||||
|
||||
virtual String getName() const
|
||||
@@ -76,7 +76,7 @@ public:
|
||||
//==============================================================================
|
||||
struct Expression::Helpers
|
||||
{
|
||||
typedef ReferenceCountedObjectPtr<Term> TermPtr;
|
||||
typedef SharedObjectPtr<Term> TermPtr;
|
||||
|
||||
static void checkRecursionDepth (const int depth)
|
||||
{
|
||||
@@ -929,13 +929,13 @@ Expression& Expression::operator= (const Expression& other)
|
||||
|
||||
#if BEAST_COMPILER_SUPPORTS_MOVE_SEMANTICS
|
||||
Expression::Expression (Expression&& other) noexcept
|
||||
: term (static_cast <ReferenceCountedObjectPtr<Term>&&> (other.term))
|
||||
: term (static_cast <SharedObjectPtr<Term>&&> (other.term))
|
||||
{
|
||||
}
|
||||
|
||||
Expression& Expression::operator= (Expression&& other) noexcept
|
||||
{
|
||||
term = static_cast <ReferenceCountedObjectPtr<Term>&&> (other.term);
|
||||
term = static_cast <SharedObjectPtr<Term>&&> (other.term);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
@@ -1077,7 +1077,7 @@ int Expression::getNumInputs() const { return term->getNumInp
|
||||
Expression Expression::getInput (int index) const { return Expression (term->getInput (index)); }
|
||||
|
||||
//==============================================================================
|
||||
ReferenceCountedObjectPtr<Expression::Term> Expression::Term::negated()
|
||||
SharedObjectPtr<Expression::Term> Expression::Term::negated()
|
||||
{
|
||||
return new Helpers::Negate (this);
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#ifndef BEAST_EXPRESSION_BEASTHEADER
|
||||
#define BEAST_EXPRESSION_BEASTHEADER
|
||||
|
||||
#include "../memory/beast_ReferenceCountedObject.h"
|
||||
#include "../memory/beast_SharedObject.h"
|
||||
#include "../containers/beast_Array.h"
|
||||
#include "../memory/beast_ScopedPointer.h"
|
||||
|
||||
@@ -260,8 +260,8 @@ private:
|
||||
friend class Term;
|
||||
friend struct Helpers;
|
||||
friend class ScopedPointer<Term>;
|
||||
friend class ReferenceCountedObjectPtr<Term>;
|
||||
ReferenceCountedObjectPtr<Term> term;
|
||||
friend class SharedObjectPtr<Term>;
|
||||
SharedObjectPtr<Term> term;
|
||||
|
||||
explicit Expression (Term*);
|
||||
};
|
||||
|
||||
@@ -32,16 +32,16 @@
|
||||
Adds reference-counting to an object.
|
||||
|
||||
To add reference-counting to a class, derive it from this class, and
|
||||
use the ReferenceCountedObjectPtr class to point to it.
|
||||
use the SharedObjectPtr class to point to it.
|
||||
|
||||
e.g. @code
|
||||
class MyClass : public ReferenceCountedObject
|
||||
class MyClass : public SharedObject
|
||||
{
|
||||
void foo();
|
||||
|
||||
// This is a neat way of declaring a typedef for a pointer class,
|
||||
// rather than typing out the full templated name each time..
|
||||
typedef ReferenceCountedObjectPtr<MyClass> Ptr;
|
||||
typedef SharedObjectPtr<MyClass> Ptr;
|
||||
};
|
||||
|
||||
MyClass::Ptr p = new MyClass();
|
||||
@@ -50,16 +50,16 @@
|
||||
p2->foo();
|
||||
@endcode
|
||||
|
||||
Once a new ReferenceCountedObject has been assigned to a pointer, be
|
||||
Once a new SharedObject has been assigned to a pointer, be
|
||||
careful not to delete the object manually.
|
||||
|
||||
This class uses an Atomic<int> value to hold the reference count, so that it
|
||||
the pointers can be passed between threads safely. For a faster but non-thread-safe
|
||||
version, use SingleThreadedReferenceCountedObject instead.
|
||||
version, use SingleThreadedSharedObject instead.
|
||||
|
||||
@see ReferenceCountedObjectPtr, ReferenceCountedArray, SingleThreadedReferenceCountedObject
|
||||
@see SharedObjectPtr, ReferenceCountedArray, SingleThreadedSharedObject
|
||||
*/
|
||||
class BEAST_API ReferenceCountedObject : Uncopyable
|
||||
class BEAST_API SharedObject : Uncopyable
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
@@ -92,12 +92,12 @@ public:
|
||||
protected:
|
||||
//==============================================================================
|
||||
/** Creates the reference-counted object (with an initial ref count of zero). */
|
||||
ReferenceCountedObject()
|
||||
SharedObject()
|
||||
{
|
||||
}
|
||||
|
||||
/** Destructor. */
|
||||
virtual ~ReferenceCountedObject()
|
||||
virtual ~SharedObject()
|
||||
{
|
||||
// it's dangerous to delete an object that's still referenced by something else!
|
||||
bassert (getReferenceCount() == 0);
|
||||
@@ -121,14 +121,14 @@ private:
|
||||
/**
|
||||
Adds reference-counting to an object.
|
||||
|
||||
This is effectively a version of the ReferenceCountedObject class, but which
|
||||
This is effectively a version of the SharedObject class, but which
|
||||
uses a non-atomic counter, and so is not thread-safe (but which will be more
|
||||
efficient).
|
||||
For more details on how to use it, see the ReferenceCountedObject class notes.
|
||||
For more details on how to use it, see the SharedObject class notes.
|
||||
|
||||
@see ReferenceCountedObject, ReferenceCountedObjectPtr, ReferenceCountedArray
|
||||
@see SharedObject, SharedObjectPtr, ReferenceCountedArray
|
||||
*/
|
||||
class BEAST_API SingleThreadedReferenceCountedObject : public Uncopyable
|
||||
class BEAST_API SingleThreadedSharedObject : public Uncopyable
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
@@ -161,10 +161,10 @@ public:
|
||||
protected:
|
||||
//==============================================================================
|
||||
/** Creates the reference-counted object (with an initial ref count of zero). */
|
||||
SingleThreadedReferenceCountedObject() : refCount (0) {}
|
||||
SingleThreadedSharedObject() : refCount (0) {}
|
||||
|
||||
/** Destructor. */
|
||||
virtual ~SingleThreadedReferenceCountedObject()
|
||||
virtual ~SingleThreadedSharedObject()
|
||||
{
|
||||
// it's dangerous to delete an object that's still referenced by something else!
|
||||
bassert (getReferenceCount() == 0);
|
||||
@@ -181,26 +181,26 @@ private:
|
||||
A smart-pointer class which points to a reference-counted object.
|
||||
|
||||
The template parameter specifies the class of the object you want to point to - the easiest
|
||||
way to make a class reference-countable is to simply make it inherit from ReferenceCountedObject,
|
||||
way to make a class reference-countable is to simply make it inherit from SharedObject,
|
||||
but if you need to, you could roll your own reference-countable class by implementing a pair of
|
||||
mathods called incReferenceCount() and decReferenceCount().
|
||||
|
||||
When using this class, you'll probably want to create a typedef to abbreviate the full
|
||||
templated name - e.g.
|
||||
@code typedef ReferenceCountedObjectPtr<MyClass> MyClassPtr;@endcode
|
||||
@code typedef SharedObjectPtr<MyClass> MyClassPtr;@endcode
|
||||
|
||||
@see ReferenceCountedObject, ReferenceCountedObjectArray
|
||||
@see SharedObject, SharedObjectArray
|
||||
*/
|
||||
template <class ReferenceCountedObjectClass>
|
||||
class ReferenceCountedObjectPtr
|
||||
template <class SharedObjectClass>
|
||||
class SharedObjectPtr
|
||||
{
|
||||
public:
|
||||
/** The class being referenced by this pointer. */
|
||||
typedef ReferenceCountedObjectClass ReferencedType;
|
||||
typedef SharedObjectClass ReferencedType;
|
||||
|
||||
//==============================================================================
|
||||
/** Creates a pointer to a null object. */
|
||||
inline ReferenceCountedObjectPtr() noexcept
|
||||
inline SharedObjectPtr() noexcept
|
||||
: referencedObject (nullptr)
|
||||
{
|
||||
}
|
||||
@@ -209,7 +209,7 @@ public:
|
||||
|
||||
This will increment the object's reference-count if it is non-null.
|
||||
*/
|
||||
inline ReferenceCountedObjectPtr (ReferenceCountedObjectClass* const refCountedObject) noexcept
|
||||
inline SharedObjectPtr (SharedObjectClass* const refCountedObject) noexcept
|
||||
: referencedObject (refCountedObject)
|
||||
{
|
||||
if (refCountedObject != nullptr)
|
||||
@@ -219,7 +219,7 @@ public:
|
||||
/** Copies another pointer.
|
||||
This will increment the object's reference-count (if it is non-null).
|
||||
*/
|
||||
inline ReferenceCountedObjectPtr (const ReferenceCountedObjectPtr& other) noexcept
|
||||
inline SharedObjectPtr (const SharedObjectPtr& other) noexcept
|
||||
: referencedObject (other.referencedObject)
|
||||
{
|
||||
if (referencedObject != nullptr)
|
||||
@@ -228,7 +228,7 @@ public:
|
||||
|
||||
#if BEAST_COMPILER_SUPPORTS_MOVE_SEMANTICS
|
||||
/** Takes-over the object from another pointer. */
|
||||
inline ReferenceCountedObjectPtr (ReferenceCountedObjectPtr&& other) noexcept
|
||||
inline SharedObjectPtr (SharedObjectPtr&& other) noexcept
|
||||
: referencedObject (other.referencedObject)
|
||||
{
|
||||
other.referencedObject = nullptr;
|
||||
@@ -239,8 +239,8 @@ public:
|
||||
This will increment the object's reference-count (if it is non-null).
|
||||
*/
|
||||
template <class DerivedClass>
|
||||
inline ReferenceCountedObjectPtr (const ReferenceCountedObjectPtr<DerivedClass>& other) noexcept
|
||||
: referencedObject (static_cast <ReferenceCountedObjectClass*> (other.get()))
|
||||
inline SharedObjectPtr (const SharedObjectPtr<DerivedClass>& other) noexcept
|
||||
: referencedObject (static_cast <SharedObjectClass*> (other.get()))
|
||||
{
|
||||
if (referencedObject != nullptr)
|
||||
referencedObject->incReferenceCount();
|
||||
@@ -251,7 +251,7 @@ public:
|
||||
The reference count of the old object is decremented, and it might be
|
||||
deleted if it hits zero. The new object's count is incremented.
|
||||
*/
|
||||
ReferenceCountedObjectPtr& operator= (const ReferenceCountedObjectPtr& other)
|
||||
SharedObjectPtr& operator= (const SharedObjectPtr& other)
|
||||
{
|
||||
return operator= (other.referencedObject);
|
||||
}
|
||||
@@ -262,14 +262,14 @@ public:
|
||||
deleted if it hits zero. The new object's count is incremented.
|
||||
*/
|
||||
template <class DerivedClass>
|
||||
ReferenceCountedObjectPtr& operator= (const ReferenceCountedObjectPtr<DerivedClass>& other)
|
||||
SharedObjectPtr& operator= (const SharedObjectPtr<DerivedClass>& other)
|
||||
{
|
||||
return operator= (static_cast <ReferenceCountedObjectClass*> (other.get()));
|
||||
return operator= (static_cast <SharedObjectClass*> (other.get()));
|
||||
}
|
||||
|
||||
#if BEAST_COMPILER_SUPPORTS_MOVE_SEMANTICS
|
||||
/** Takes-over the object from another pointer. */
|
||||
ReferenceCountedObjectPtr& operator= (ReferenceCountedObjectPtr&& other)
|
||||
SharedObjectPtr& operator= (SharedObjectPtr&& other)
|
||||
{
|
||||
std::swap (referencedObject, other.referencedObject);
|
||||
return *this;
|
||||
@@ -281,14 +281,14 @@ public:
|
||||
The reference count of the old object is decremented, and it might be
|
||||
deleted if it hits zero. The new object's count is incremented.
|
||||
*/
|
||||
ReferenceCountedObjectPtr& operator= (ReferenceCountedObjectClass* const newObject)
|
||||
SharedObjectPtr& operator= (SharedObjectClass* const newObject)
|
||||
{
|
||||
if (referencedObject != newObject)
|
||||
{
|
||||
if (newObject != nullptr)
|
||||
newObject->incReferenceCount();
|
||||
|
||||
ReferenceCountedObjectClass* const oldObject = referencedObject;
|
||||
SharedObjectClass* const oldObject = referencedObject;
|
||||
referencedObject = newObject;
|
||||
|
||||
if (oldObject != nullptr)
|
||||
@@ -303,7 +303,7 @@ public:
|
||||
This will decrement the object's reference-count, and may delete it if it
|
||||
gets to zero.
|
||||
*/
|
||||
inline ~ReferenceCountedObjectPtr()
|
||||
inline ~SharedObjectPtr()
|
||||
{
|
||||
if (referencedObject != nullptr)
|
||||
referencedObject->decReferenceCount();
|
||||
@@ -312,13 +312,13 @@ public:
|
||||
/** Returns the object that this pointer references.
|
||||
The pointer returned may be zero, of course.
|
||||
*/
|
||||
inline operator ReferenceCountedObjectClass*() const noexcept
|
||||
inline operator SharedObjectClass*() const noexcept
|
||||
{
|
||||
return referencedObject;
|
||||
}
|
||||
|
||||
// the -> operator is called on the referenced object
|
||||
inline ReferenceCountedObjectClass* operator->() const noexcept
|
||||
inline SharedObjectClass* operator->() const noexcept
|
||||
{
|
||||
return referencedObject;
|
||||
}
|
||||
@@ -326,7 +326,7 @@ public:
|
||||
/** Returns the object that this pointer references.
|
||||
The pointer returned may be zero, of course.
|
||||
*/
|
||||
inline ReferenceCountedObjectClass* get() const noexcept
|
||||
inline SharedObjectClass* get() const noexcept
|
||||
{
|
||||
return referencedObject;
|
||||
}
|
||||
@@ -334,55 +334,55 @@ public:
|
||||
/** Returns the object that this pointer references.
|
||||
The pointer returned may be zero, of course.
|
||||
*/
|
||||
inline ReferenceCountedObjectClass* getObject() const noexcept
|
||||
inline SharedObjectClass* getObject() const noexcept
|
||||
{
|
||||
return referencedObject;
|
||||
}
|
||||
|
||||
private:
|
||||
//==============================================================================
|
||||
ReferenceCountedObjectClass* referencedObject;
|
||||
SharedObjectClass* referencedObject;
|
||||
};
|
||||
|
||||
|
||||
/** Compares two ReferenceCountedObjectPointers. */
|
||||
template <class ReferenceCountedObjectClass>
|
||||
bool operator== (const ReferenceCountedObjectPtr<ReferenceCountedObjectClass>& object1, ReferenceCountedObjectClass* const object2) noexcept
|
||||
/** Compares two SharedObjectPointers. */
|
||||
template <class SharedObjectClass>
|
||||
bool operator== (const SharedObjectPtr<SharedObjectClass>& object1, SharedObjectClass* const object2) noexcept
|
||||
{
|
||||
return object1.get() == object2;
|
||||
}
|
||||
|
||||
/** Compares two ReferenceCountedObjectPointers. */
|
||||
template <class ReferenceCountedObjectClass>
|
||||
bool operator== (const ReferenceCountedObjectPtr<ReferenceCountedObjectClass>& object1, const ReferenceCountedObjectPtr<ReferenceCountedObjectClass>& object2) noexcept
|
||||
/** Compares two SharedObjectPointers. */
|
||||
template <class SharedObjectClass>
|
||||
bool operator== (const SharedObjectPtr<SharedObjectClass>& object1, const SharedObjectPtr<SharedObjectClass>& object2) noexcept
|
||||
{
|
||||
return object1.get() == object2.get();
|
||||
}
|
||||
|
||||
/** Compares two ReferenceCountedObjectPointers. */
|
||||
template <class ReferenceCountedObjectClass>
|
||||
bool operator== (ReferenceCountedObjectClass* object1, ReferenceCountedObjectPtr<ReferenceCountedObjectClass>& object2) noexcept
|
||||
/** Compares two SharedObjectPointers. */
|
||||
template <class SharedObjectClass>
|
||||
bool operator== (SharedObjectClass* object1, SharedObjectPtr<SharedObjectClass>& object2) noexcept
|
||||
{
|
||||
return object1 == object2.get();
|
||||
}
|
||||
|
||||
/** Compares two ReferenceCountedObjectPointers. */
|
||||
template <class ReferenceCountedObjectClass>
|
||||
bool operator!= (const ReferenceCountedObjectPtr<ReferenceCountedObjectClass>& object1, const ReferenceCountedObjectClass* object2) noexcept
|
||||
/** Compares two SharedObjectPointers. */
|
||||
template <class SharedObjectClass>
|
||||
bool operator!= (const SharedObjectPtr<SharedObjectClass>& object1, const SharedObjectClass* object2) noexcept
|
||||
{
|
||||
return object1.get() != object2;
|
||||
}
|
||||
|
||||
/** Compares two ReferenceCountedObjectPointers. */
|
||||
template <class ReferenceCountedObjectClass>
|
||||
bool operator!= (const ReferenceCountedObjectPtr<ReferenceCountedObjectClass>& object1, ReferenceCountedObjectPtr<ReferenceCountedObjectClass>& object2) noexcept
|
||||
/** Compares two SharedObjectPointers. */
|
||||
template <class SharedObjectClass>
|
||||
bool operator!= (const SharedObjectPtr<SharedObjectClass>& object1, SharedObjectPtr<SharedObjectClass>& object2) noexcept
|
||||
{
|
||||
return object1.get() != object2.get();
|
||||
}
|
||||
|
||||
/** Compares two ReferenceCountedObjectPointers. */
|
||||
template <class ReferenceCountedObjectClass>
|
||||
bool operator!= (ReferenceCountedObjectClass* object1, ReferenceCountedObjectPtr<ReferenceCountedObjectClass>& object2) noexcept
|
||||
/** Compares two SharedObjectPointers. */
|
||||
template <class SharedObjectClass>
|
||||
bool operator!= (SharedObjectClass* object1, SharedObjectPtr<SharedObjectClass>& object2) noexcept
|
||||
{
|
||||
return object1 != object2.get();
|
||||
}
|
||||
@@ -107,7 +107,7 @@ protected:
|
||||
}
|
||||
|
||||
public:
|
||||
typedef ReferenceCountedObjectPtr <Object> Ptr;
|
||||
typedef SharedObjectPtr <Object> Ptr;
|
||||
|
||||
/** Retrieve a reference to the singleton.
|
||||
*/
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#ifndef BEAST_WEAKREFERENCE_BEASTHEADER
|
||||
#define BEAST_WEAKREFERENCE_BEASTHEADER
|
||||
|
||||
#include "beast_ReferenceCountedObject.h"
|
||||
#include "beast_SharedObject.h"
|
||||
|
||||
|
||||
//==============================================================================
|
||||
@@ -75,7 +75,7 @@
|
||||
|
||||
@see WeakReference::Master
|
||||
*/
|
||||
template <class ObjectType, class ReferenceCountingType = ReferenceCountedObject>
|
||||
template <class ObjectType, class ReferenceCountingType = SharedObject>
|
||||
class WeakReference
|
||||
{
|
||||
public:
|
||||
@@ -142,7 +142,7 @@ public:
|
||||
ObjectType* volatile owner;
|
||||
};
|
||||
|
||||
typedef ReferenceCountedObjectPtr<SharedPointer> SharedRef;
|
||||
typedef SharedObjectPtr<SharedPointer> SharedRef;
|
||||
|
||||
//==============================================================================
|
||||
/**
|
||||
|
||||
@@ -48,11 +48,11 @@ Thread::~Thread()
|
||||
//==============================================================================
|
||||
// Use a ref-counted object to hold this shared data, so that it can outlive its static
|
||||
// shared pointer when threads are still running during static shutdown.
|
||||
struct CurrentThreadHolder : public ReferenceCountedObject
|
||||
struct CurrentThreadHolder : public SharedObject
|
||||
{
|
||||
CurrentThreadHolder() noexcept {}
|
||||
|
||||
typedef ReferenceCountedObjectPtr <CurrentThreadHolder> Ptr;
|
||||
typedef SharedObjectPtr <CurrentThreadHolder> Ptr;
|
||||
ThreadLocalValue<Thread*> value;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user