SNMP++  3.3.4
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: reentrant.h 2359 2013-05-09 20:07:01Z fock $
28 
29 #ifndef _reentrant_h_
30 #define _reentrant_h_
31 
32 #include "snmp_pp/config_snmp_pp.h"
33 #include "snmp_pp/smi.h"
34 
35 #ifdef _THREADS
36 #ifdef WIN32
37 #include <process.h>
38 #elif defined (CPU) && CPU == PPC603
39 #include <semLib.h>
40 #else
41 #include <pthread.h>
42 #endif
43 #endif
44 
45 #ifdef SNMP_PP_NAMESPACE
46 namespace Snmp_pp {
47 #endif
48 
50 
51  public:
53  virtual ~SnmpSynchronized();
54 #ifdef _THREADS
55 #ifdef WIN32
56  CRITICAL_SECTION _mutex;
57 #elif defined (CPU) && CPU == PPC603
58  SEM_ID _mutex;
59 #else
60  pthread_mutex_t _mutex;
61 #endif
62 #endif
63  void lock();
64  void unlock();
65 };
66 
68 
69  public:
70  SnmpSynchronize(SnmpSynchronized& sync) : s(sync) { s.lock(); };
71  ~SnmpSynchronize() { s.unlock(); }
72 
73  protected:
75 
76 };
77 
78 #define REENTRANT(x) { SnmpSynchronize _synchronize(*this); x }
79 
80 #ifdef SNMP_PP_NAMESPACE
81 } // end of namespace Snmp_pp
82 #endif
83 
84 #endif
85 
SnmpSynchronize(SnmpSynchronized &sync)
Definition: reentrant.h:70
#define DLLOPT
pthread_mutex_t _mutex
Definition: reentrant.h:60
SnmpSynchronized & s
Definition: reentrant.h:74