Oracle® Fusion Middleware C++ API Reference for Oracle Coherence
12c (12.2.1.3.0)

E80355-01

coherence/lang/AbstractHeapAnalyzer.hpp

00001 /*
00002 * AbstractHeapAnalyzer.hpp
00003 *
00004 * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
00005 *
00006 * Oracle is a registered trademarks of Oracle Corporation and/or its
00007 * affiliates.
00008 *
00009 * This software is the confidential and proprietary information of Oracle
00010 * Corporation. You shall not disclose such confidential and proprietary
00011 * information and shall use it only in accordance with the terms of the
00012 * license agreement you entered into with Oracle.
00013 *
00014 * This notice may not be removed or altered.
00015 */
00016 #ifndef COH_ABSTRACT_HEAP_ANALYZER_HPP
00017 #define COH_ABSTRACT_HEAP_ANALYZER_HPP
00018 
00019 #include "coherence/lang/compatibility.hpp"
00020 
00021 
00022 #include "coherence/lang/abstract_spec.hpp"
00023 #include "coherence/lang/HeapAnalyzer.hpp"
00024 
00025 
00026 
00027 COH_OPEN_NAMESPACE2(coherence,native)
00028 class NativeThreadLocal;
00029 COH_CLOSE_NAMESPACE2
00030 
00031 COH_OPEN_NAMESPACE2(coherence,lang)
00032 
00033 using coherence::native::NativeThreadLocal;
00034 
00035 
00036 /**
00037 * AbstractHeapAnalyzer provides a starting point for writing custom heap
00038 * analyzers. Most notably it includes support for detecting analyzer
00039 * re-entrance so that analyzers can avoid endlessly recursing if they create
00040 * objects as part of the registration process.
00041 *
00042 * @author mf  2008.04.27
00043 */
00044 class COH_EXPORT AbstractHeapAnalyzer
00045     : public abstract_spec<AbstractHeapAnalyzer,
00046         extends<Object>,
00047         implements<HeapAnalyzer> >
00048     {
00049     // ----- constructor ----------------------------------------------------
00050 
00051     protected:
00052         /**
00053         * @internal
00054         */
00055         AbstractHeapAnalyzer();
00056 
00057         /**
00058         * @internal
00059         */
00060         virtual ~AbstractHeapAnalyzer();
00061 
00062 
00063     // ----- AbstractHeapAnalyzer methods -----------------------------------
00064 
00065     protected:
00066         /**
00067         * Registers an object with the heap analyzer.
00068         *
00069         * @param o  the object to register
00070         */
00071         virtual void safeRegisterObject(const Object& o) = 0;
00072 
00073         /**
00074         * Unregisters an object with the heap analyzer.
00075         *
00076         * @param o  the object to unregister
00077         */
00078         virtual void safeUnregisterObject(const Object& o) = 0;
00079 
00080 
00081     // ----- HeapAnalyzer interface -----------------------------------------
00082 
00083     protected:
00084         /**
00085         * {@inheritDoc}
00086         *
00087         * @param o  the object to register
00088         *
00089         * If the calling thread is reentering this method return immediately
00090         * otherwise delegates to safeRegisterObject.
00091         */
00092         virtual void registerObject(const Object& o);
00093 
00094         /**
00095         * {@inheritDoc}
00096         *
00097         * @param o  the object to unregister
00098         *
00099         * If the calling thread is reentering this method return immediately
00100         * otherwise delegates to safeUnregisterObject.
00101         */
00102         virtual void unregisterObject(const Object& o);
00103 
00104 
00105     // ----- Object interface -----------------------------------------------
00106 
00107     public:
00108         /**
00109         * Capture a snapshot and output it to the supplied stream.
00110         *
00111         * @param out  the stream to output to
00112         */
00113         virtual TypedHandle<const String> toString() const;
00114 
00115 
00116     // ----- data members ---------------------------------------------------
00117 
00118     private:
00119         /**
00120         * Tracks if the calling thread is within the analyzer.
00121         *
00122         * The use of ThreadLocalReference here is not suitable, as it is a
00123         * managed object, and causes recursion into the HeapAnalyzer.
00124         */
00125         NativeThreadLocal* const m_pTLContext;
00126     };
00127 
00128 COH_CLOSE_NAMESPACE2
00129 
00130 #endif // COH_ABSTRACT_HEAP_ANALYZER_HPP
Copyright © 2000, 2017, Oracle and/or its affiliates. All rights reserved.