ZeroCopyAllocator_T.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #ifndef ZEROCOPYALLOCATOR_H
00009 #define ZEROCOPYALLOCATOR_H
00010
00011 #include "ace/pre.h"
00012 #include "ace/Malloc_Base.h"
00013
00014
00015 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00016 # pragma once
00017 #endif
00018
00019 #include "dds/Versioned_Namespace.h"
00020
00021 OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
00022
00023 namespace OpenDDS {
00024 namespace DCPS {
00025
00026
00027
00028
00029
00030
00031 template <class T, std::size_t N>
00032 class FirstTimeFastAllocator : public ACE_Allocator {
00033 public:
00034 FirstTimeFastAllocator();
00035 virtual void *malloc(size_t nbytes);
00036 virtual void free(void *ptr);
00037
00038
00039 virtual void *calloc(size_t nbytes, char initial_value = '\0');
00040 virtual void *calloc(size_t n_elem, size_t elem_size, char initial_value = '\0');
00041 virtual int remove();
00042 virtual int bind(const char *name, void *pointer, int duplicates = 0);
00043 virtual int trybind(const char *name, void *&pointer);
00044 virtual int find(const char *name, void *&pointer);
00045 virtual int find(const char *name);
00046 virtual int unbind(const char *name);
00047 virtual int unbind(const char *name, void *&pointer);
00048 virtual int sync(ssize_t len = -1, int flags = MS_SYNC);
00049 virtual int sync(void *addr, size_t len, int flags = MS_SYNC);
00050 virtual int protect(ssize_t len = -1, int prot = PROT_RDWR);
00051 virtual int protect(void *addr, size_t len, int prot = PROT_RDWR);
00052 #if defined (ACE_HAS_MALLOC_STATS)
00053 virtual void print_stats() const;
00054 #endif
00055 virtual void dump() const;
00056
00057 T* pool() {
00058 return pool_;
00059 }
00060
00061 private:
00062
00063 bool firstTime_;
00064
00065
00066 T pool_[N];
00067 };
00068
00069 }
00070 }
00071
00072 OPENDDS_END_VERSIONED_NAMESPACE_DECL
00073
00074 #if defined (__ACE_INLINE__)
00075 #include "dds/DCPS/ZeroCopyAllocator_T.inl"
00076 #endif
00077
00078 #if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
00079 #include "dds/DCPS/ZeroCopyAllocator_T.cpp"
00080 #endif
00081
00082 #if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
00083 #pragma implementation ("ZeroCopyAllocator_T.cpp")
00084 #endif
00085
00086 #include "ace/post.h"
00087
00088 #endif