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

« back to all changes in this revision

Viewing changes to src/xmlrpcpp/XmlRpcMutex.h

  • Committer: Package Import Robot
  • Author(s): Kamal Mostafa
  • Date: 2014-06-07 11:28:52 UTC
  • Revision ID: package-import@ubuntu.com-20140607112852-v4d5tb1m3h3vi0dl
Tags: upstream-1.3.15
ImportĀ upstreamĀ versionĀ 1.3.15

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef _XMLRPCMUTEX_H_
 
2
#define _XMLRPCMUTEX_H_
 
3
//
 
4
// XmlRpc++ Copyright (c) 2002-2003 by Chris Morley
 
5
//
 
6
#if defined(_MSC_VER)
 
7
# pragma warning(disable:4786)    // identifier was truncated in debug info
 
8
#endif
 
9
 
 
10
namespace XmlRpc {
 
11
 
 
12
  //! A simple platform-independent mutex API implemented for posix and windows.
 
13
  class XmlRpcMutex {
 
14
  public:
 
15
    //! Construct a Mutex object.
 
16
    XmlRpcMutex() : _pMutex(0) {}
 
17
 
 
18
    //! Destroy a Mutex object.
 
19
    ~XmlRpcMutex();
 
20
 
 
21
    //! Wait for the mutex to be available and then acquire the lock.
 
22
    void acquire();
 
23
 
 
24
    //! Release the mutex.
 
25
    void release();
 
26
 
 
27
    //! Utility class to acquire a mutex at construction and release it when destroyed.
 
28
    struct AutoLock {
 
29
      //! Acquire the mutex at construction
 
30
      AutoLock(XmlRpcMutex& m) : _m(m) { _m.acquire(); }
 
31
      //! Release at destruction
 
32
      ~AutoLock() { _m.release(); }
 
33
      //! The mutex being held
 
34
      XmlRpcMutex& _m;
 
35
    };
 
36
 
 
37
  private:
 
38
 
 
39
    //! Native Mutex object
 
40
    void* _pMutex;
 
41
 
 
42
  };  // class XmlRpcMutex
 
43
 
 
44
}  // namespace XmlRpc
 
45
 
 
46
#endif  //  _XMLRPCMUTEX_H_