dom/camera/AutoRwLock.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
     3  * You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 #ifndef RWLOCK_AUTO_ENTER_H
     6 #define RWLOCK_AUTO_ENTER_H
     8 #include "prrwlock.h"
     9 #include "mozilla/Assertions.h"
    11 class RwLockAutoEnterRead
    12 {
    13 public:
    14   RwLockAutoEnterRead(PRRWLock* aRwLock)
    15     : mRwLock(aRwLock)
    16   {
    17     MOZ_ASSERT(mRwLock);
    18     PR_RWLock_Rlock(mRwLock);
    19   }
    21   ~RwLockAutoEnterRead()
    22   {
    23     PR_RWLock_Unlock(mRwLock);
    24   }
    26 protected:
    27   PRRWLock* mRwLock;
    28 };
    30 class RwLockAutoEnterWrite
    31 {
    32 public:
    33   RwLockAutoEnterWrite(PRRWLock* aRwLock)
    34     : mRwLock(aRwLock)
    35   {
    36     MOZ_ASSERT(mRwLock);
    37     PR_RWLock_Wlock(mRwLock);
    38   }
    40   ~RwLockAutoEnterWrite()
    41   {
    42     PR_RWLock_Unlock(mRwLock);
    43   }
    45 protected:
    46   PRRWLock* mRwLock;
    47 };
    49 #endif // RWLOCK_AUTO_ENTER_H

mercurial