Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 /*
7 ** C++ access to NSPR locks (PRLock)
8 */
10 #if defined(_RCLOCK_H)
11 #else
12 #define _RCLOCK_H
14 #include "rcbase.h"
16 #include <prlock.h>
18 class PR_IMPLEMENT(RCLock): public RCBase
19 {
20 public:
21 RCLock();
22 virtual ~RCLock();
24 void Acquire(); /* non-reentrant */
25 void Release(); /* should be by owning thread */
27 friend class RCCondition;
29 private:
30 RCLock(const RCLock&); /* can't do that */
31 void operator=(const RCLock&); /* nor that */
33 PRLock *lock;
34 }; /* RCLock */
36 /*
37 ** Class: RCEnter
38 **
39 ** In scope locks. You can only allocate them on the stack. The language
40 ** will insure that they get released (by calling the destructor) when
41 ** the thread leaves scope, even if via an exception.
42 */
43 class PR_IMPLEMENT(RCEnter)
44 {
45 public:
46 ~RCEnter(); /* releases the lock */
47 RCEnter(RCLock*); /* acquires the lock */
49 private:
50 RCLock *lock;
52 RCEnter();
53 RCEnter(const RCEnter&);
54 void operator=(const RCEnter&);
56 void *operator new(PRSize) { return NULL; }
57 void operator delete(void*) { }
58 }; /* RCEnter */
61 inline RCEnter::RCEnter(RCLock* ml) { lock = ml; lock->Acquire(); }
62 inline RCEnter::~RCEnter() { lock->Release(); lock = NULL; }
64 #endif /* defined(_RCLOCK_H) */
66 /* RCLock.h */