VirtualBox

source: vbox/trunk/src/VBox/Main/AutoLock.cpp@ 21426

Last change on this file since 21426 was 20932, checked in by vboxsync, 15 years ago

Main/AutoLock: eliminate not entirely working custom windows implementation. IPRT based one works.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Date Revision Author Id
File size: 1.7 KB
Line 
1/** @file
2 *
3 * AutoWriteLock/AutoReadLock: smart R/W semaphore wrappers
4 */
5
6/*
7 * Copyright (C) 2006-2008 Sun Microsystems, Inc.
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
18 * Clara, CA 95054 USA or visit http://www.sun.com if you need
19 * additional information or have any questions.
20 */
21
22#include "AutoLock.h"
23
24#include "Logging.h"
25
26#include <iprt/string.h>
27
28
29namespace util
30{
31
32RWLockHandle::RWLockHandle()
33{
34 int vrc = RTSemRWCreate (&mSemRW);
35 AssertRC (vrc);
36}
37
38
39RWLockHandle::~RWLockHandle()
40{
41 RTSemRWDestroy (mSemRW);
42}
43
44
45bool RWLockHandle::isWriteLockOnCurrentThread() const
46{
47 return RTSemRWIsWriteOwner (mSemRW);
48}
49
50
51void RWLockHandle::lockWrite()
52{
53 int vrc = RTSemRWRequestWrite (mSemRW, RT_INDEFINITE_WAIT);
54 AssertRC (vrc);
55}
56
57
58void RWLockHandle::unlockWrite()
59{
60 int vrc = RTSemRWReleaseWrite (mSemRW);
61 AssertRC (vrc);
62}
63
64
65void RWLockHandle::lockRead()
66{
67 int vrc = RTSemRWRequestRead (mSemRW, RT_INDEFINITE_WAIT);
68 AssertRC (vrc);
69}
70
71
72void RWLockHandle::unlockRead()
73{
74 int vrc = RTSemRWReleaseRead (mSemRW);
75 AssertRC (vrc);
76}
77
78
79uint32_t RWLockHandle::writeLockLevel() const
80{
81 return RTSemRWGetWriteRecursion (mSemRW);
82}
83
84} /* namespace util */
85/* vi: set tabstop=4 shiftwidth=4 expandtab: */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette