diff options
author | Xanadu <none@none> | 2010-07-20 02:49:28 +0200 |
---|---|---|
committer | Xanadu <none@none> | 2010-07-20 02:49:28 +0200 |
commit | 79622802f397258ee0f34327ba3ae6977ca3e7ff (patch) | |
tree | 1868946c234ab9ee256a6b7766a15713eae94235 /externals/g3dlite/G3D/MemoryManager.h | |
parent | 7dd2dc91816ab8b3bc3b99a1b1c99c7ea314d5a8 (diff) | |
parent | f906976837502fa5aa81b982b901d1509f5aa0c4 (diff) |
Merge. Revision history for source files should be all back now.
--HG--
branch : trunk
rename : sql/CMakeLists.txt => sql/tools/CMakeLists.txt
rename : src/server/game/Pools/PoolHandler.cpp => src/server/game/Pools/PoolMgr.cpp
rename : src/server/game/Pools/PoolHandler.h => src/server/game/Pools/PoolMgr.h
rename : src/server/game/PrecompiledHeaders/NixCorePCH.cpp => src/server/game/PrecompiledHeaders/gamePCH.cpp
rename : src/server/game/PrecompiledHeaders/NixCorePCH.h => src/server/game/PrecompiledHeaders/gamePCH.h
Diffstat (limited to 'externals/g3dlite/G3D/MemoryManager.h')
-rw-r--r-- | externals/g3dlite/G3D/MemoryManager.h | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/externals/g3dlite/G3D/MemoryManager.h b/externals/g3dlite/G3D/MemoryManager.h new file mode 100644 index 00000000000..15bf6d8be43 --- /dev/null +++ b/externals/g3dlite/G3D/MemoryManager.h @@ -0,0 +1,93 @@ +/** + @file MemoryManager.h + + @maintainer Morgan McGuire, http://graphics.cs.williams.edu + @created 2009-04-20 + @edited 2009-04-20 + + Copyright 2000-2009, Morgan McGuire. + All rights reserved. + */ +#ifndef G3D_MemoryManager_h +#define G3D_MemoryManager_h + +#include "G3D/platform.h" +#include "G3D/ReferenceCount.h" + +namespace G3D { + +/** + Abstraction of memory management. + Default implementation uses G3D::System::malloc and is threadsafe. + + \sa CRTMemoryManager, AlignedMemoryManager, AreaMemoryManager */ +class MemoryManager : public ReferenceCountedObject { +protected: + + MemoryManager(); + +public: + + typedef ReferenceCountedPointer<class MemoryManager> Ref; + + /** Return a pointer to \a s bytes of memory that are unused by + the rest of the program. The contents of the memory are + undefined */ + virtual void* alloc(size_t s); + + /** Invoke to declare that this memory will no longer be used by + the program. The memory manager is not required to actually + reuse or release this memory. */ + virtual void free(void* ptr); + + /** Returns true if this memory manager is threadsafe (i.e., alloc + and free can be called asychronously) */ + virtual bool isThreadsafe() const; + + /** Return the instance. There's only one instance of the default + MemoryManager; it is cached after the first creation. */ + static MemoryManager::Ref create(); +}; + +/** + Allocates memory on 16-byte boundaries. + \sa MemoryManager, CRTMemoryManager, AreaMemoryManager */ +class AlignedMemoryManager : public MemoryManager { +protected: + + AlignedMemoryManager(); + +public: + + typedef ReferenceCountedPointer<class AlignedMemoryManager> Ref; + + + virtual void* alloc(size_t s); + + virtual void free(void* ptr); + + virtual bool isThreadsafe() const; + + static AlignedMemoryManager::Ref create(); +}; + + +/** MemoryManager implemented using the C runtime. */ +class CRTMemoryManager : public MemoryManager { +protected: + CRTMemoryManager(); + +public: + typedef ReferenceCountedPointer<class MemoryManager> Ref; + virtual void* alloc(size_t s); + virtual void free(void* ptr); + virtual bool isThreadsafe() const; + + /** There's only one instance of this memory manager; it is + cached after the first creation. */ + static CRTMemoryManager::Ref create(); +}; + +} + +#endif |