Imported Upstream version 5.3.21
[platform/upstream/libdb.git] / lang / csharp / src / MutexConfig.cs
1 /*-
2  * See the file LICENSE for redistribution information.
3  *
4  * Copyright (c) 2009, 2012 Oracle and/or its affiliates.  All rights reserved.
5  *
6  */
7 using System;
8 using System.Collections.Generic;
9 using System.Text;
10 using BerkeleyDB.Internal;
11
12 namespace BerkeleyDB {
13     /// <summary>
14     /// A class representing configuration parameters for a
15     /// <see cref="DatabaseEnvironment"/>'s mutex subsystem.
16     /// </summary>
17     public class MutexConfig {
18         internal bool alignmentIsSet;
19         private uint _alignment;
20         /// <summary>
21         /// The mutex alignment, in bytes.
22         /// </summary>
23         /// <remarks>
24         /// <para>
25         /// It is sometimes advantageous to align mutexes on specific byte
26         /// boundaries in order to minimize cache line collisions. Alignment
27         /// specifies an alignment for mutexes allocated by Berkeley DB.
28         /// </para>
29         /// <para>
30         /// If the database environment already exists when
31         /// <see cref="DatabaseEnvironment.Open"/> is called, the value of
32         /// Alignment will be ignored.
33         /// </para>
34         /// </remarks>
35         public uint Alignment {
36             get { return _alignment; }
37             set {
38                 alignmentIsSet = true;
39                 _alignment = value;
40             }
41         }
42
43         internal bool incrementIsSet;
44         private uint _increment;
45         /// <summary>
46         /// Configure the number of additional mutexes to allocate.
47         /// </summary>
48         /// <remarks>
49         /// <para>
50         /// If both Increment and <see cref="MaxMutexes"/> are set, the value of
51         /// Increment will be silently ignored.
52         /// </para>
53         /// <para>
54         /// If the database environment already exists when
55         /// <see cref="DatabaseEnvironment.Open"/> is called, the value of
56         /// Increment will be ignored.
57         /// </para>
58         /// </remarks>
59         public uint Increment {
60             get { return _increment; }
61             set {
62                 incrementIsSet = true;
63                 _increment = value;
64             }
65         }
66
67         internal bool initMutexesIsSet;
68         private uint _initmutexes;
69         /// <summary>
70         /// The initial number of mutexes to allocate.
71         /// </summary>
72         /// <remarks>
73         /// <para>
74         /// Berkeley DB allocates a default number of mutexes based on the
75         /// initial configuration of the database environment. This method
76         /// allows the user to override that default value.
77         /// </para>
78         /// <para>
79         /// If the database environment already exists when
80         /// <see cref="DatabaseEnvironment.Open"/> is called, the value of
81         /// InitMutexes will be ignored.
82         /// </para>
83         /// </remarks>
84         public uint InitMutexes {
85             get { return _initmutexes; }
86             set {
87                 initMutexesIsSet = true;
88                 _initmutexes = value;
89             }
90         }
91
92         internal bool maxMutexesIsSet;
93         private uint _maxmutexes;
94         /// <summary>
95         /// The total number of mutexes to allocate.
96         /// </summary>
97         /// <remarks>
98         /// <para>
99         /// Berkeley DB allocates a default number of mutexes based on the
100         /// initial configuration of the database environment. That default
101         /// calculation may be too small if the application has an unusual need
102         /// for mutexes (for example, if the application opens an unexpectedly
103         /// large number of databases) or too large (if the application is
104         /// trying to minimize its memory footprint). MaxMutexes is used to
105         /// specify an absolute number of mutexes to allocate.
106         /// </para>
107         /// <para>
108         /// If both <see cref="Increment"/> and MaxMutexes are set, the value of
109         /// Increment will be silently ignored.
110         /// </para>
111         /// <para>
112         /// If the database environment already exists when
113         /// <see cref="DatabaseEnvironment.Open"/> is called, the value of
114         /// MaxMutexes will be ignored.
115         /// </para>
116         /// </remarks>
117         public uint MaxMutexes {
118             get { return _maxmutexes; }
119             set {
120                 maxMutexesIsSet = true;
121                 _maxmutexes = value;
122             }
123         }
124
125         internal bool numTASIsSet;
126         private uint _numTAS;
127         /// <summary>
128         /// The number of spins test-and-set mutexes should execute before
129         /// blocking. 
130         /// </summary>
131         public uint NumTestAndSetSpins {
132             get { return _numTAS; }
133             set {
134                 numTASIsSet = true;
135                 _numTAS = value;
136             }
137         }
138
139         
140     }
141 }