~ubuntu-branches/ubuntu/wily/flrig/wily

« back to all changes in this revision

Viewing changes to .pc/0001-License-Declaration.patch/src/xmlrpcpp/XmlRpcMutex.cpp

  • Committer: Package Import Robot
  • Author(s): Kamal Mostafa
  • Date: 2014-10-25 11:17:10 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20141025111710-n32skgya3l9u1brw
Tags: 1.3.17-1
* New upstream release (Closes: #761839)
* Debian Standards-Version: 3.9.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#if defined(XMLRPC_THREADS)
2
 
 
3
 
#include "XmlRpcMutex.h"
4
 
 
5
 
#if defined(_WINDOWS)
6
 
# define WIN32_LEAN_AND_MEAN
7
 
# include <windows.h>
8
 
#else
9
 
# include <pthread.h>
10
 
#endif
11
 
 
12
 
using namespace XmlRpc;
13
 
 
14
 
 
15
 
//! Destructor.
16
 
XmlRpcMutex::~XmlRpcMutex()
17
 
{
18
 
  if (_pMutex)
19
 
  {
20
 
#if defined(_WINDOWS)
21
 
    ::CloseHandle((HANDLE)_pMutex);
22
 
#else
23
 
    ::pthread_mutex_destroy((pthread_mutex_t*)_pMutex);
24
 
    delete _pMutex;
25
 
#endif
26
 
    _pMutex = 0;
27
 
  }
28
 
}
29
 
 
30
 
//! Wait for the mutex to be available and then acquire the lock.
31
 
void XmlRpcMutex::acquire()
32
 
{
33
 
#if defined(_WINDOWS)
34
 
  if ( ! _pMutex)
35
 
    _pMutex = ::CreateMutex(0, TRUE, 0);
36
 
  else
37
 
    ::WaitForSingleObject(_pMutex, INFINITE);
38
 
#else
39
 
  if ( ! _pMutex)
40
 
  {
41
 
    _pMutex = new pthread_mutex_t;
42
 
    ::pthread_mutex_init((pthread_mutex_t*)_pMutex, 0);
43
 
  }
44
 
  ::pthread_mutex_lock((pthread_mutex_t*)_pMutex);
45
 
#endif
46
 
}
47
 
 
48
 
//! Release the mutex.
49
 
void XmlRpcMutex::release()
50
 
{
51
 
  if (_pMutex)
52
 
#if defined(_WINDOWS)
53
 
    ::ReleaseMutex(_pMutex);
54
 
#else
55
 
    ::pthread_mutex_unlock((pthread_mutex_t*)_pMutex);
56
 
#endif
57
 
}
58
 
 
59
 
#endif // XMLRPC_THREADS
60