summaryrefslogtreecommitdiff
path: root/csharp/Mutex.cs
blob: e3d683b7f8f236200ecdf6e22cdd2ef0672425a0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*-
 * See the file LICENSE for redistribution information.
 *
 * Copyright (c) 2009 Oracle.  All rights reserved.
 *
 */
using System;
using System.Collections.Generic;
using System.Text;

namespace BerkeleyDB {
    internal class Mutex : IDisposable {
        private DatabaseEnvironment env;

        private uint val;
        
        internal Mutex(DatabaseEnvironment owner, uint mutexValue) {
            env = owner;
            val = mutexValue;
        }

        internal void Lock() {
            env.dbenv.mutex_lock(val);
        }

        internal void Unlock() {
            env.dbenv.mutex_unlock(val);
        }

        public void Dispose() {
            env.dbenv.mutex_free(val);
            GC.SuppressFinalize(this);
        }
    }
}