00001 /*_############################################################################ 00002 _## 00003 _## reentrant.h 00004 _## 00005 _## SNMP++v3.2.15 00006 _## ----------------------------------------------- 00007 _## Copyright (c) 2001-2004 Jochen Katz, Frank Fock 00008 _## 00009 _## This software is based on SNMP++2.6 from Hewlett Packard: 00010 _## 00011 _## Copyright (c) 1996 00012 _## Hewlett-Packard Company 00013 _## 00014 _## ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS. 00015 _## Permission to use, copy, modify, distribute and/or sell this software 00016 _## and/or its documentation is hereby granted without fee. User agrees 00017 _## to display the above copyright notice and this license notice in all 00018 _## copies of the software and any documentation of the software. User 00019 _## agrees to assume all liability for the use of the software; 00020 _## Hewlett-Packard and Jochen Katz make no representations about the 00021 _## suitability of this software for any purpose. It is provided 00022 _## "AS-IS" without warranty of any kind, either express or implied. User 00023 _## hereby grants a royalty-free license to any and all derivatives based 00024 _## upon this software code base. 00025 _## 00026 _## Stuttgart, Germany, Tue Jan 4 21:42:42 CET 2005 00027 _## 00028 _##########################################################################*/ 00029 // $Id: reentrant.h,v 1.4 2004/03/03 23:11:21 katz Exp $ 00030 00031 #ifndef _reentrant_h_ 00032 #define _reentrant_h_ 00033 00034 #include "snmp_pp/config_snmp_pp.h" 00035 #include "snmp_pp/smi.h" 00036 00037 #ifdef _THREADS 00038 #ifdef WIN32 00039 #include <winsock.h> 00040 #include <process.h> 00041 #else 00042 #include <pthread.h> 00043 #endif 00044 #endif 00045 00046 #ifdef SNMP_PP_NAMESPACE 00047 namespace Snmp_pp { 00048 #endif 00049 00050 class DLLOPT SnmpSynchronized { 00051 00052 public: 00053 SnmpSynchronized(); 00054 virtual ~SnmpSynchronized(); 00055 #ifdef _THREADS 00056 #ifdef WIN32 00057 CRITICAL_SECTION _mutex; 00058 #else 00059 pthread_mutex_t _mutex; 00060 #endif 00061 #endif 00062 void lock(); 00063 void unlock(); 00064 }; 00065 00066 class DLLOPT SnmpSynchronize { 00067 00068 public: 00069 SnmpSynchronize(SnmpSynchronized& sync) : s(sync) { s.lock(); }; 00070 ~SnmpSynchronize() { s.unlock(); } 00071 00072 protected: 00073 SnmpSynchronized& s; 00074 00075 }; 00076 00077 #define REENTRANT(x) { SnmpSynchronize _synchronize(*this); x } 00078 00079 #ifdef SNMP_PP_NAMESPACE 00080 }; // end of namespace Snmp_pp 00081 #endif 00082 00083 #endif 00084
1.3.2