Mixe for Privacy and Anonymity in the Internet
CAMutex.cpp
Go to the documentation of this file.
1 /*
2 Copyright (c) 2000, The JAP-Team
3 All rights reserved.
4 Redistribution and use in source and binary forms, with or without modification,
5 are permitted provided that the following conditions are met:
6 
7  - Redistributions of source code must retain the above copyright notice,
8  this list of conditions and the following disclaimer.
9 
10  - Redistributions in binary form must reproduce the above copyright notice,
11  this list of conditions and the following disclaimer in the documentation and/or
12  other materials provided with the distribution.
13 
14  - Neither the name of the University of Technology Dresden, Germany nor the names of its contributors
15  may be used to endorse or promote products derived from this software without specific
16  prior written permission.
17 
18 
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS
20 OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
21 AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS
22 BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
24 OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25 IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE
27 */
28 #include "StdAfx.h"
29 #include "CAMutex.hpp"
30 #include "CAMsg.hpp"
31 
32 
34 {
35  #ifdef HAVE_PTHREAD_MUTEXES
36  m_pMutex=new pthread_mutex_t;
37  //m_pMutexAttributes = new pthread_mutexattr_t;
38  //pthread_mutexattr_init(m_pMutexAttributes);
39  //pthread_mutexattr_settype(m_pMutexAttributes, PTHREAD_MUTEX_RECURSIVE);
40  //pthread_mutexattr_settype(m_pMutexAttributes, PTHREAD_MUTEX_ERRORCHECK);
41  //pthread_mutex_init(m_pMutex, m_pMutexAttributes);
42  pthread_mutex_init(m_pMutex, NULL);
43  #else
44  m_pMutex=new CASemaphore(1);
45  #endif
46 }
47 
49 {
50  #ifdef HAVE_PTHREAD_MUTEXES
51  pthread_mutex_destroy(m_pMutex);
52  //pthread_mutexattr_destroy(m_pMutexAttributes);
53  #endif
54  delete m_pMutex;
55  m_pMutex = NULL;
56 
57  #ifdef HAVE_PTHREAD_MUTEXES
58  //delete m_pMutexAttributes;
59  #endif
60 }
CASemaphore * m_pMutex
Definition: CAMutex.hpp:69
CAMutex()
Definition: CAMutex.cpp:33
virtual ~CAMutex()
Definition: CAMutex.cpp:48