00001 /**************************************************************************** 00002 * MeshLab o o * 00003 * A versatile mesh processing toolbox o o * 00004 * _ O _ * 00005 * Copyright(C) 2005 \/)\/ * 00006 * Visual Computing Lab /\/| * 00007 * ISTI - Italian National Research Council | * 00008 * \ * 00009 * All rights reserved. * 00010 * * 00011 * This program is free software; you can redistribute it and/or modify * 00012 * it under the terms of the GNU General Public License as published by * 00013 * the Free Software Foundation; either version 2 of the License, or * 00014 * (at your option) any later version. * 00015 * * 00016 * This program is distributed in the hope that it will be useful, * 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00019 * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * 00020 * for more details. * 00021 * * 00022 ****************************************************************************/ 00023 00024 #include "ml_thread_safe_memory_info.h" 00025 00026 MLThreadSafeMemoryInfo::MLThreadSafeMemoryInfo( std::ptrdiff_t originalmem ) 00027 :vcg::NotThreadSafeMemoryInfo(originalmem),lock(QReadWriteLock::Recursive) 00028 { 00029 00030 } 00031 00032 MLThreadSafeMemoryInfo::~MLThreadSafeMemoryInfo() 00033 { 00034 } 00035 00036 void MLThreadSafeMemoryInfo::acquiredMemory(std::ptrdiff_t mem) 00037 { 00038 QWriteLocker locker(&lock); 00039 vcg::NotThreadSafeMemoryInfo::acquiredMemory(mem); 00040 } 00041 00042 std::ptrdiff_t MLThreadSafeMemoryInfo::usedMemory() const 00043 { 00044 QReadLocker locker(&lock); 00045 return vcg::NotThreadSafeMemoryInfo::usedMemory(); 00046 00047 } 00048 00049 std::ptrdiff_t MLThreadSafeMemoryInfo::currentFreeMemory() const 00050 { 00051 QReadLocker locker(&lock); 00052 return vcg::NotThreadSafeMemoryInfo::currentFreeMemory(); 00053 } 00054 00055 void MLThreadSafeMemoryInfo::releasedMemory(std::ptrdiff_t mem) 00056 { 00057 QWriteLocker locker(&lock); 00058 vcg::NotThreadSafeMemoryInfo::releasedMemory(mem); 00059 } 00060 00061 bool MLThreadSafeMemoryInfo::isAdditionalMemoryAvailable( std::ptrdiff_t mem ) 00062 { 00063 QReadLocker locker(&lock); 00064 return vcg::NotThreadSafeMemoryInfo::isAdditionalMemoryAvailable(mem); 00065 }