reSIProcate
SIP stack, Dialog Usage Manager and related libraries
Loading...
Searching...
No Matches
Lock.hxx
Go to the documentation of this file.
1#if !defined(RESIP_LOCK_HXX)
2#define RESIP_LOCK_HXX
3
4#include "rutil/Mutex.hxx"
5#include "rutil/RWMutex.hxx"
6
7namespace resip
8{
9
17/*
18 * We removed our local implementation and now we use the
19 * C++11 library
20 *
21 * We could use either std::lock_guard or std::unique_lock here
22 * for similar results.
23 *
24 * To make the resip::Lock useful with std::condition_variable,
25 * we must use std::unique_lock
26 */
27
28typedef std::unique_lock<Mutex> Lock;
29typedef std::unique_lock<RecursiveMutex> RecursiveLock;
30
32{
33 public:
35 virtual ~ReadLock();
36 private:
37 RWMutex& mLockable;
38};
39
41{
42 public:
44 virtual ~WriteLock();
45 private:
46 RWMutex& mLockable;
47};
48
49
50
57{
58 public:
59 PtrLock(Mutex*);
60 virtual ~PtrLock();
61
62 private:
63 Mutex* myLockable;
64};
65
66} // namespace resip
67
68#endif
69
70/* ====================================================================
71 * The Vovida Software License, Version 1.0
72 *
73 * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
74 *
75 * Redistribution and use in source and binary forms, with or without
76 * modification, are permitted provided that the following conditions
77 * are met:
78 *
79 * 1. Redistributions of source code must retain the above copyright
80 * notice, this list of conditions and the following disclaimer.
81 *
82 * 2. Redistributions in binary form must reproduce the above copyright
83 * notice, this list of conditions and the following disclaimer in
84 * the documentation and/or other materials provided with the
85 * distribution.
86 *
87 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
88 * and "Vovida Open Communication Application Library (VOCAL)" must
89 * not be used to endorse or promote products derived from this
90 * software without prior written permission. For written
91 * permission, please contact vocal@vovida.org.
92 *
93 * 4. Products derived from this software may not be called "VOCAL", nor
94 * may "VOCAL" appear in their name, without prior written
95 * permission of Vovida Networks, Inc.
96 *
97 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
98 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
99 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
100 * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
101 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
102 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
103 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
104 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
105 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
106 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
107 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
108 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
109 * DAMAGE.
110 *
111 * ====================================================================
112 *
113 * This software consists of voluntary contributions made by Vovida
114 * Networks, Inc. and many individuals on behalf of Vovida Networks,
115 * Inc. For more information on Vovida Networks, Inc., please see
116 * <http://www.vovida.org/>.
117 *
118 */
Much like class Lock above, but takes pointer argument to Lockable, which may be NULL.
Definition Lock.hxx:57
virtual ~PtrLock()
Definition Lock.cxx:41
Wraps the readers/writers mutex implementation on your platform.
Definition RWMutex.hxx:29
virtual ~ReadLock()
Definition Lock.cxx:17
virtual ~WriteLock()
Definition Lock.cxx:28
dcm! – add UnusedChecking(_enum) below;
std::mutex Mutex
A semaphore that can be locked by only one thread at a time.
Definition Mutex.hxx:37
std::unique_lock< RecursiveMutex > RecursiveLock
Definition Lock.hxx:29
std::unique_lock< Mutex > Lock
A convenience class to lock a Lockable (such as a Mutex) on object creation, and unlock on destructio...
Definition Lock.hxx:28