- Timestamp:
- 10/18/13 13:28:43 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Mars/mcore/MemoryManager.h
r17219 r17250 21 21 22 22 public: 23 MemoryStock(size_t chunk, size_t max) : fChunkSize(chunk), fMaxMemory(max ),23 MemoryStock(size_t chunk, size_t max) : fChunkSize(chunk), fMaxMemory(max<chunk?chunk:max), 24 24 fInUse(0), fAllocated(0), fMaxInUse(0) 25 25 { 26 if (chunk>max)27 throw std::runtime_error("Size mismatch: Size of a single chunk exceeds maximum size of memory");28 26 } 29 27 … … 138 136 139 137 size_t getChunkSize() const { return fMemoryStock->fChunkSize; } 140 voidsetChunkSize(const size_t size)138 bool setChunkSize(const size_t size) 141 139 { 142 if (getInUse() != 0) 140 #ifdef __EXCEPTIONS 141 if (getInUse()) 143 142 throw std::runtime_error("Cannot change the chunk size while there is memory in use"); 143 if (getMaxMemory()<size) 144 throw std::runtime_error("Chunk size("+to_string(size)+") larger thann allowed memory ("+to_string(getMaxMemory())+")"); 145 #else 146 if (getInUse() || getMaxMemory()<size) 147 return false; 144 148 145 if (getMaxMemory() < size)146 {147 std::ostringstream str;148 str << "Chunk size(" << size << ") larger thank allowed memory(" << getMaxMemory() << "). Cannot allocate a single chunk.";149 throw std::runtime_error(str.str());150 }151 149 fMemoryStock->fChunkSize = size; 150 return true; 152 151 } 152 153 153 size_t getMaxMemory() const { return fMemoryStock->fMaxMemory; } 154 154 size_t getInUse() const { return fMemoryStock->fInUse; }
Note:
See TracChangeset
for help on using the changeset viewer.