00001 // vim:set et sts=4 ts=4 tw=75 sw=4 ai ci cin cino=g0,t0: 00002 /* 00003 * Copyright (C) 2007, Technical Computer Science Group, 00004 * University of Bonn 00005 * 00006 * This file is part of the ReChannel library. 00007 * 00008 * The ReChannel library is free software; you can redistribute it and/or 00009 * modify it under the terms of the GNU General Public License as 00010 * published by the Free Software Foundation; either version 2 of the 00011 * License, or (at your option) any later version. 00012 * 00013 * This library is distributed in the hope that it will be 00014 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 * General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU General Public License 00019 * along with this library; see the file COPYING. If not, write to the 00020 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, 00021 * Boston, MA 02110-1301, USA. 00022 * 00023 * Authors: Andreas Raabe and Armin Felke. Implementation by Armin Felke. 00024 * {raabe, felke}@cs.uni-bonn.de 00025 */ 00037 #ifndef RC_MUTEX_FILTER_H_ 00038 #define RC_MUTEX_FILTER_H_ 00039 00040 #include "ReChannel/communication/filters/rc_abstract_filter.h" 00041 00042 namespace ReChannel { 00043 00047 class rc_mutex_filter 00048 : public rc_abstract_filter<sc_mutex_if> 00049 { 00050 00051 private: 00052 typedef rc_abstract_filter<sc_mutex_if> base_type; 00053 typedef rc_mutex_filter this_type; 00054 00055 public: 00056 rc_mutex_filter(rc_transaction_counter& tc) 00057 : m_tc(tc) 00058 { } 00059 00060 virtual int lock() 00061 { 00062 base_type::lock(); 00063 ++m_tc; 00064 return 0; 00065 } 00066 virtual int trylock() 00067 { 00068 const int ret = base_type::trylock(); 00069 if (ret == 0) { 00070 ++m_tc; 00071 } 00072 return ret; 00073 } 00074 virtual int unlock() 00075 { 00076 const int ret = base_type::unlock(); 00077 if (ret == 0) { 00078 --m_tc; 00079 } 00080 return ret; 00081 } 00082 00083 protected: 00084 00085 rc_transaction_counter& m_tc; 00086 00087 private: 00088 // disabled 00089 rc_mutex_filter(const this_type& other_); 00090 this_type& operator=(const this_type& other_); 00091 }; 00092 00093 } // namespace ReChannel 00094 00095 #endif // RC_MUTEX_FILTER_H_ 00096 00097 // 00098 // $Id: rc_mutex_filter.h,v 1.4 2007/12/06 11:42:43 felke Exp $ 00099 // $Source: /var/cvs/projekte/ReChannel-v2/src/ReChannel/communication/filters/rc_mutex_filter.h,v $ 00100 //