C++ Client API Reference for Oracle Coherence
14c (14.1.2.0.0)

F79659-03

coherence/net/cache/AbstractEntryBundler.hpp

00001 /*
00002  * Copyright (c) 2000, 2020, Oracle and/or its affiliates.
00003  *
00004  * Licensed under the Universal Permissive License v 1.0 as shown at
00005  * http://oss.oracle.com/licenses/upl.
00006  */
00007 #ifndef COH_ABSTRACT_ENTRY_BUNDLER_HPP
00008 #define COH_ABSTRACT_ENTRY_BUNDLER_HPP
00009 
00010 #include "coherence/lang.ns"
00011 
00012 #include "coherence/net/cache/AbstractBundler.hpp"
00013 
00014 #include "coherence/util/AtomicCounter.hpp"
00015 #include "coherence/util/Collections.hpp"
00016 #include "coherence/util/Map.hpp"
00017 #include "coherence/util/SafeHashMap.hpp"
00018 
00019 COH_OPEN_NAMESPACE3(coherence,net,cache)
00020 
00021 using coherence::util::AtomicCounter;
00022 using coherence::util::Collections;
00023 using coherence::util::Map;
00024 using coherence::util::SafeHashMap;
00025 
00026 /**
00027  * An abstract entry-based bundler serves as a base for NamedCache::put()
00028  * operation bundling.
00029  *
00030  * @author gg 2007.01.28
00031  * @author lh 2012.05.06
00032  * @since Coherence 12.1.2
00033  */
00034 class COH_EXPORT AbstractEntryBundler
00035     : public abstract_spec<AbstractEntryBundler,
00036         extends<AbstractBundler> >
00037     {
00038     // ----- handle definitions (needed for nested classes) -----------------
00039 
00040     public:
00041         typedef this_spec::Handle Handle;
00042         typedef this_spec::View   View;
00043         typedef this_spec::Holder Holder;
00044 
00045     // ----- constructors ---------------------------------------------------
00046 
00047     protected:
00048        /**
00049         * @internal
00050         */
00051         AbstractEntryBundler();
00052 
00053     private:
00054        /**
00055         * Blocked copy constructor.
00056         */
00057         AbstractEntryBundler(const AbstractEntryBundler&);
00058 
00059     // ----- bundling support -----------------------------------------------
00060 
00061     public:
00062         /**
00063          * Process the specified entry in a most optimal way according to the
00064          * bundle settings.
00065          *
00066          * @param vKey     the entry key
00067          * @param ohValue  the entry value
00068          */
00069         virtual void process(Object::View vKey, Object::Holder ohValue);
00070     
00071         /**
00072          * Process a colllection of entries in a most optimal way according to the
00073          * bundle settings.
00074          *
00075          * @param vMap  the collection of entries to process
00076          */
00077         virtual void processAll(Map::View vMap);
00078 
00079     // ----- subclassing support --------------------------------------------
00080 
00081     protected:
00082         /**
00083          * The bundle operation to be performed against a collected map of entries
00084          * by the concrete AbstractEntryBundler implementations. If an exception
00085          * occurs during bundle operation, it will be repeated using singleton maps.
00086          *
00087          * @param vMapEntries  a map to perform the bundled operation for
00088          */
00089         virtual void bundle(Map::View vMapEntries) = 0;
00090 
00091     // ----- AbstractBundler methods ----------------------------------------
00092 
00093         /**
00094          * {@inheritDoc}
00095          */
00096         virtual AbstractBundler::Bundle::Handle instantiateBundle();
00097 
00098     // ----- inner class: Bundle --------------------------------------------
00099 
00100     /*
00101      * Bundle represents a unit of optimized execution.
00102      */
00103     protected:
00104         class COH_EXPORT Bundle
00105             : public class_spec<Bundle,
00106                 extends<AbstractBundler::Bundle> >
00107         {
00108         friend class factory<AbstractEntryBundler::Bundle>;
00109 
00110         protected:
00111             /**
00112              * Default constructor.
00113              *
00114              * @param hBundler  the AbstructBundler
00115              */
00116              Bundle(AbstractBundler::Handle hBundler);
00117 
00118         // ----- bundling support ---------------------------------------
00119 
00120         public:
00121             /**
00122              * Add the specified entry to the Bundle.
00123              *
00124              * <b>Note:</b> a call to this method must be externally synchronized
00125              * for this Bundle object.
00126              *
00127              * @param vKey     the entry key
00128              * @param ohValue  the entry value
00129              *
00130              * @return true if this Bundle was empty prior to this call
00131              */
00132             virtual bool add(Object::View vKey, Object::Holder ohValue);
00133 
00134             /**
00135              * Add the specified collection of entries to the Bundle.
00136              *
00137              * <b>Note:</b> a call to this method must be externally synchronized
00138              * for this Bundle object.
00139              *
00140              * @param vMap  the collection of entries
00141              *
00142              * @return true if this Bundle was empty prior to this call
00143              */
00144             virtual bool addAll(Map::View vMap);
00145 
00146             /**
00147              * Process the specified entry according to this Bundle state.
00148              *
00149              * @param fBurst   true if this thread is supposed to perform an actual
00150              *                 bundled operation (burst); false otherwise
00151              * @param vKey     the entry key
00152              * @param ohValue  the entry value
00153              */
00154             virtual void process(bool fBurst, Object::View vKey, Object::Holder ohValue);
00155 
00156             /**
00157              * Process the specified collection of entries according to this Bundle
00158              * state.
00159              *
00160              * @param fBurst  true if this thread is supposed to perform an actual
00161              *                bundled operation (burst); false otherwise
00162              * @param vMap    the collection of entries
00163              */
00164             virtual void processAll(bool fBurst, Map::View vMap);
00165 
00166             // ----- AbstractBundler::Bundle methods---------------------
00167 
00168             /**
00169              * {@inheritDoc}
00170              */
00171             virtual int32_t getBundleSize() const;
00172 
00173             /**
00174              * {@inheritDoc}
00175              */
00176             using AbstractBundler::Bundle::ensureResults;
00177 
00178             /**
00179              * {@inheritDoc}
00180              */
00181             virtual void ensureResults();
00182 
00183             /**
00184              * {@inheritDoc}
00185              */
00186             virtual bool releaseThread();
00187 
00188         // ----- data fileds --------------------------------------------
00189 
00190         private:
00191             /**
00192              * This bundle content.
00193              */
00194             FinalHandle<Map> f_hMapEntries;
00195         };
00196     };
00197     
00198 COH_CLOSE_NAMESPACE3
00199     
00200 #endif // COH_ABSTRACT_ENTRY_BUNDLER_HPP
Copyright © 2000, 2025, Oracle and/or its affiliates. Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.