ml_thread_safe_memory_info.h
Go to the documentation of this file.
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 #ifndef __ML_THREAD_SAFE_MEMORY_INFO_H
00025 #define __ML_THREAD_SAFE_MEMORY_INFO_H
00026 
00027 #include <QReadWriteLock>
00028 
00029 #include <wrap/system/memory_info.h>
00030 
00031 
00032 class MLThreadSafeMemoryInfo : public vcg::NotThreadSafeMemoryInfo
00033 {
00034 public:
00035         MLThreadSafeMemoryInfo(std::ptrdiff_t originalmem);
00036 
00037         ~MLThreadSafeMemoryInfo();
00038 
00039         void acquiredMemory(std::ptrdiff_t mem);
00040 
00041         std::ptrdiff_t usedMemory() const;
00042 
00043         std::ptrdiff_t currentFreeMemory() const;
00044 
00045         void releasedMemory(std::ptrdiff_t mem = 0);
00046         
00047         bool isAdditionalMemoryAvailable(std::ptrdiff_t mem);
00048 private:
00049         //mutable objects can be modified from the declared const functions
00050         //in this way we have not to modified the basic vcg::MemoryInfo interface for the logically const functions
00051         //whose need to lock the mutex for a simple reading operation
00052         mutable QReadWriteLock lock;
00053 };
00054 
00055 #endif


shape_reconstruction
Author(s): Roberto Martín-Martín
autogenerated on Sat Jun 8 2019 18:33:22