1/*-
2 * See the file LICENSE for redistribution information.
3 *
4 * Copyright (c) 2009 Oracle.  All rights reserved.
5 *
6 */
7using System;
8using System.Collections.Generic;
9using System.Text;
10
11namespace BerkeleyDB {
12    internal class Mutex : IDisposable {
13        private DatabaseEnvironment env;
14
15        private uint val;
16
17        internal Mutex(DatabaseEnvironment owner, uint mutexValue) {
18            env = owner;
19            val = mutexValue;
20        }
21
22        internal void Lock() {
23            env.dbenv.mutex_lock(val);
24        }
25
26        internal void Unlock() {
27            env.dbenv.mutex_unlock(val);
28        }
29
30        public void Dispose() {
31            env.dbenv.mutex_free(val);
32            GC.SuppressFinalize(this);
33        }
34    }
35}
36