LCOV - code coverage report
Current view: top level - DCPS - ZeroCopyAllocator_T.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 2 0.0 %
Date: 2023-04-30 01:32:43 Functions: 0 1 0.0 %

          Line data    Source code
       1             : /*
       2             :  * Distributed under the OpenDDS License.
       3             :  * See: http://www.opendds.org/license.html
       4             :  */
       5             : 
       6             : #ifndef OPENDDS_DCPS_ZEROCOPYALLOCATOR_T_H
       7             : #define OPENDDS_DCPS_ZEROCOPYALLOCATOR_T_H
       8             : 
       9             : #include <ace/config-macros.h>
      10             : #ifndef ACE_LACKS_PRAGMA_ONCE
      11             : #  pragma once
      12             : #endif
      13             : 
      14             : #include <dds/Versioned_Namespace.h>
      15             : 
      16             : #include <ace/Malloc_Base.h> /* Need ACE_Allocator */
      17             : 
      18             : OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
      19             : 
      20             : namespace OpenDDS {
      21             : namespace DCPS {
      22             : 
      23             : /// This allocator is "Fast" because it's pool can be on the stack
      24             : ///   (If the object is on the stack and hence it does not require the
      25             : ///    cost of allocating and deallocating on the heap.  It object is on the
      26             : ///    heap then it requires just one allocation; not two.)
      27             : /// *WARNING* The object using this allocator must not have a scope smaller than this object !!!
      28             : template <class T, std::size_t N>
      29             : class FirstTimeFastAllocator : public ACE_Allocator {
      30             : public:
      31             :   FirstTimeFastAllocator();
      32             :   virtual void *malloc(size_t nbytes);
      33             :   virtual void free(void *ptr);
      34             : 
      35             :   /// These methods are no-ops.
      36             :   virtual void *calloc(size_t nbytes, char initial_value = '\0');
      37             :   virtual void *calloc(size_t n_elem, size_t elem_size, char initial_value = '\0');
      38             :   virtual int remove();
      39             :   virtual int bind(const char *name, void *pointer, int duplicates = 0);
      40             :   virtual int trybind(const char *name, void *&pointer);
      41             :   virtual int find(const char *name, void *&pointer);
      42             :   virtual int find(const char *name);
      43             :   virtual int unbind(const char *name);
      44             :   virtual int unbind(const char *name, void *&pointer);
      45             :   virtual int sync(ssize_t len = -1, int flags = MS_SYNC);
      46             :   virtual int sync(void *addr, size_t len, int flags = MS_SYNC);
      47             :   virtual int protect(ssize_t len = -1, int prot = PROT_RDWR);
      48             :   virtual int protect(void *addr, size_t len, int prot = PROT_RDWR);
      49             : #if defined (ACE_HAS_MALLOC_STATS)
      50             :   virtual void print_stats() const;
      51             : #endif /* ACE_HAS_MALLOC_STATS */
      52             :   virtual void dump() const;
      53             : 
      54           0 :   T* pool() {
      55           0 :     return pool_;
      56             :   }
      57             : 
      58             : private:
      59             :   /// is this the first time this is allocated?
      60             :   bool firstTime_;
      61             : 
      62             :   /// the pool of allocated memory.
      63             :   T pool_[N];
      64             : };
      65             : 
      66             : } // namespace  DDS
      67             : } // namespace OpenDDS
      68             : 
      69             : OPENDDS_END_VERSIONED_NAMESPACE_DECL
      70             : 
      71             : #if defined (__ACE_INLINE__)
      72             : #include "ZeroCopyAllocator_T.inl"
      73             : #endif /* __ACE_INLINE__ */
      74             : 
      75             : #if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
      76             : #include "ZeroCopyAllocator_T.cpp"
      77             : #endif /* ACE_TEMPLATES_REQUIRE_SOURCE */
      78             : 
      79             : #if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
      80             : #pragma implementation ("ZeroCopyAllocator_T.cpp")
      81             : #endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */
      82             : 
      83             : #endif /* ZEROCOPYALLOCATOR_H  */

Generated by: LCOV version 1.16