SNMP++  3.3.11
reentrant.h
Go to the documentation of this file.
1 /*_############################################################################
2  _##
3  _## reentrant.h
4  _##
5  _## SNMP++ v3.3
6  _## -----------------------------------------------
7  _## Copyright (c) 2001-2013 Jochen Katz, Frank Fock
8  _##
9  _## This software is based on SNMP++2.6 from Hewlett Packard:
10  _##
11  _## Copyright (c) 1996
12  _## Hewlett-Packard Company
13  _##
14  _## ATTENTION: USE OF THIS SOFTWARE IS SUBJECT TO THE FOLLOWING TERMS.
15  _## Permission to use, copy, modify, distribute and/or sell this software
16  _## and/or its documentation is hereby granted without fee. User agrees
17  _## to display the above copyright notice and this license notice in all
18  _## copies of the software and any documentation of the software. User
19  _## agrees to assume all liability for the use of the software;
20  _## Hewlett-Packard and Jochen Katz make no representations about the
21  _## suitability of this software for any purpose. It is provided
22  _## "AS-IS" without warranty of any kind, either express or implied. User
23  _## hereby grants a royalty-free license to any and all derivatives based
24  _## upon this software code base.
25  _##
26  _##########################################################################*/
27 // $Id$
28 
29 #ifndef _SNMP_REENTRANT_H_
30 #define _SNMP_REENTRANT_H_
31 
32 #include <libsnmp.h>
33 #include "snmp_pp/config_snmp_pp.h"
34 #include "snmp_pp/smi.h"
35 
36 #ifdef _THREADS
37 #ifdef WIN32
38 #include <process.h>
39 #elif defined (CPU) && CPU == PPC603
40 #include <semLib.h>
41 #else
42 #include <pthread.h>
43 #endif
44 #endif
45 
46 #ifdef SNMP_PP_NAMESPACE
47 namespace Snmp_pp {
48 #endif
49 
51 
52  public:
54  virtual ~SnmpSynchronized();
55 #ifdef _THREADS
56 #ifdef WIN32
57  CRITICAL_SECTION _mutex;
58 #elif defined (CPU) && CPU == PPC603
59  SEM_ID _mutex;
60 #else
61  pthread_mutex_t _mutex;
62 #endif
63 #endif
64  void lock();
65  void unlock();
66 };
67 
69 
70  public:
71  SnmpSynchronize(SnmpSynchronized& sync) : s(sync) { s.lock(); };
72  ~SnmpSynchronize() { s.unlock(); }
73 
74  protected:
76 
77 };
78 
79 #define REENTRANT(x) { SnmpSynchronize _synchronize(*this); x }
80 
81 #ifdef SNMP_PP_NAMESPACE
82 } // end of namespace Snmp_pp
83 #endif
84 
85 #endif // _SNMP_REENTRANT_H_
SnmpSynchronize(SnmpSynchronized &sync)
Definition: reentrant.h:71
#define DLLOPT
pthread_mutex_t _mutex
Definition: reentrant.h:61
SnmpSynchronized & s
Definition: reentrant.h:75