Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

MNRopeRefCount.h

Go to the documentation of this file.
00001 /* 00002 * Copyright (c) 1997 00003 * Silicon Graphics Computer Systems, Inc. 00004 * 00005 * Permission to use, copy, modify, distribute and sell this software 00006 * and its documentation for any purpose is hereby granted without fee, 00007 * provided that the above copyright notice appear in all copies and 00008 * that both that copyright notice and this permission notice appear 00009 * in supporting documentation. Silicon Graphics makes no 00010 * representations about the suitability of this software for any 00011 * purpose. It is provided "as is" without express or implied warranty. 00012 * 00013 * Heavily modified by KOM/Darmstadt University of Technology, 2000 00014 */ 00015 #ifndef _R_REF_COUNT_H 00016 #define _R_REF_COUNT_H 00017 00018 #include "mnthread.h" 00019 00020 #include <sys/types.h> 00021 #include <string.h> 00022 #include <stdlib.h> 00023 00028 // Class MNRopeRefCount provides a type, size_t, a data member, 00029 // _M_ref_count, and member functions _M_incr and _M_decr, which perform 00030 // atomic preincrement/predecrement. The constructor initializes 00031 // _M_ref_count. 00032 00033 struct MNRopeRefCount 00034 { 00035 // The data member _M_ref_count 00036 volatile size_t _M_ref_count; 00037 00038 // Constructor 00039 /* #ifdef _THREAD_SAFE */ 00040 mnthread_mutex_t _M_ref_count_lock; 00041 /* # endif */ 00042 00043 MNRopeRefCount(size_t __n); 00044 00045 virtual ~MNRopeRefCount(); 00046 00047 // _M_incr and _M_decr 00048 void _M_incr(); 00049 size_t _M_decr(); 00050 }; 00051 00052 static inline int max( int a, int b ) 00053 { 00054 if ( a > b ) return a; 00055 return b; 00056 } 00057 00058 static inline int min( int a, int b ) 00059 { 00060 if ( a < b ) return a; 00061 return b; 00062 } 00063 /* 00064 * There is an STL header file for these functions 00065 */ 00066 inline void uninitialized_copy_n( const uchar_t* src, size_t len, uchar_t* dest ) 00067 { 00068 memmove(dest,src,len); 00069 } 00070 00071 inline void copy_n( const uchar_t* src, size_t len, uchar_t* dest ) 00072 { 00073 memmove(dest,src,len); 00074 } 00075 00076 inline void uninitialized_fill_n( uchar_t* dest, size_t len, uchar_t c ) 00077 { 00078 memset(dest,c,len); 00079 } 00080 00081 /* 00082 * Destroy calls destructor code without releasing memory. 00083 * In this case, we don't care. 00084 */ 00085 inline void destroy( uchar_t* /* bits */, size_t /* len */ ) 00086 { } 00087 00088 inline void destroy( uchar_t* /* from */, uchar_t* /* to */ ) 00089 { } 00090 00092 00093 #endif /* _R_REF_COUNT_H */ 00094

Generated on Sun Mar 6 13:35:49 2005 for Komssys by doxygen 1.3.8