From 39f13beaf71b9d578d5f03ef99b220e925aee46c Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Wed, 18 Sep 2013 11:52:33 -0700 Subject: [PATCH] Remove unused ConcurrentObject --- Builds/VisualStudio2012/beast.vcxproj | 7 -- Builds/VisualStudio2012/beast.vcxproj.filters | 6 -- .../thread/beast_ConcurrentObject.cpp | 76 ------------------ .../thread/beast_ConcurrentObject.h | 79 ------------------- 4 files changed, 168 deletions(-) delete mode 100644 modules/beast_core/thread/beast_ConcurrentObject.cpp delete mode 100644 modules/beast_core/thread/beast_ConcurrentObject.h diff --git a/Builds/VisualStudio2012/beast.vcxproj b/Builds/VisualStudio2012/beast.vcxproj index ed9877d731..9fe63f9391 100644 --- a/Builds/VisualStudio2012/beast.vcxproj +++ b/Builds/VisualStudio2012/beast.vcxproj @@ -283,7 +283,6 @@ - @@ -1079,12 +1078,6 @@ true true - - true - true - true - true - true true diff --git a/Builds/VisualStudio2012/beast.vcxproj.filters b/Builds/VisualStudio2012/beast.vcxproj.filters index 5292b52f91..a98e789c3f 100644 --- a/Builds/VisualStudio2012/beast.vcxproj.filters +++ b/Builds/VisualStudio2012/beast.vcxproj.filters @@ -701,9 +701,6 @@ beast_core\thread - - beast_core\thread - beast_core\thread @@ -1384,9 +1381,6 @@ beast_core\thread - - beast_core\thread - beast_core\thread diff --git a/modules/beast_core/thread/beast_ConcurrentObject.cpp b/modules/beast_core/thread/beast_ConcurrentObject.cpp deleted file mode 100644 index 56ace3e98a..0000000000 --- a/modules/beast_core/thread/beast_ConcurrentObject.cpp +++ /dev/null @@ -1,76 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -class ConcurrentObject::Deleter : private ThreadWithCallQueue::EntryPoints -{ -private: - Deleter () : m_thread ("AsyncDeleter") - { - m_thread.start (this); - } - - ~Deleter () - { - m_thread.stop (true); - } - - void onExit () - { - //delete this; - } - - static void doDelete (ConcurrentObject* sharedObject) - { - delete sharedObject; - } - -public: - void destroy (ConcurrentObject* sharedObject) - { - if (m_thread.isAssociatedWithCurrentThread ()) - delete sharedObject; - else - m_thread.call (&Deleter::doDelete, sharedObject); - } - - static Deleter& getInstance () - { - static Deleter instance; - - return instance; - } - -private: - ThreadWithCallQueue m_thread; -}; - -//------------------------------------------------------------------------------ - -ConcurrentObject::ConcurrentObject () -{ -} - -ConcurrentObject::~ConcurrentObject () -{ -} - -void ConcurrentObject::destroyConcurrentObject () -{ - Deleter::getInstance ().destroy (this); -} diff --git a/modules/beast_core/thread/beast_ConcurrentObject.h b/modules/beast_core/thread/beast_ConcurrentObject.h deleted file mode 100644 index e298e900f6..0000000000 --- a/modules/beast_core/thread/beast_ConcurrentObject.h +++ /dev/null @@ -1,79 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of Beast: https://github.com/vinniefalco/Beast - Copyright 2013, Vinnie Falco - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef BEAST_CONCURRENTOBJECT_H_INCLUDED -#define BEAST_CONCURRENTOBJECT_H_INCLUDED - -/*============================================================================*/ -/** - A reference counted object with overridable destroy behavior. - - This is a reference counted object compatible with - ReferenceCountedObjectPtr. When the last reference is removed, the - object is queued for deletion on a separate, provided thread. On - program exit the thread will clean itself up - no other action is - required. - - This class is useful for offloading the deletion work of "deep" objects - shared by multiple threads: objects containing complex members, or a - hierarchy of allocated structures. For example, a ValueTree. The problem - of performing heavyweight memory or cleanup operations from either an - AudioIODeviceCallback or the message thread is avoided. - - The deletion behavior can be overriden by providing a replacement - for destroyConcurrentObject(). - - @ingroup beast_concurrent -*/ -class BEAST_API ConcurrentObject : Uncopyable -{ -public: - inline void incReferenceCount () noexcept - { - m_refs.addref (); - } - - inline void decReferenceCount () noexcept - { - if (m_refs.release ()) - destroyConcurrentObject (); - } - -protected: - ConcurrentObject (); - - virtual ~ConcurrentObject (); - - /** Delete the object. - - This function is called when the reference count drops to zero. The - default implementation performs the delete on a separate, provided thread - that cleans up after itself on exit. - */ - virtual void destroyConcurrentObject (); - -protected: - class Deleter; - -private: - AtomicCounter m_refs; -}; - -#endif -