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; 10using BerkeleyDB.Internal; 11 12namespace 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 maxIsSet; 68 private uint _max; 69 /// <summary> 70 /// The total 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. That default 76 /// calculation may be too small if the application has an unusual need 77 /// for mutexes (for example, if the application opens an unexpectedly 78 /// large number of databases) or too large (if the application is 79 /// trying to minimize its memory footprint). MaxMutexes is used to 80 /// specify an absolute number of mutexes to allocate. 81 /// </para> 82 /// <para> 83 /// If both <see cref="Increment"/> and MaxMutexes are set, the value of 84 /// Increment will be silently ignored. 85 /// </para> 86 /// <para> 87 /// If the database environment already exists when 88 /// <see cref="DatabaseEnvironment.Open"/> is called, the value of 89 /// MaxMutexes will be ignored. 90 /// </para> 91 /// </remarks> 92 public uint MaxMutexes { 93 get { return _max; } 94 set { 95 maxIsSet = true; 96 _max = value; 97 } 98 } 99 100 internal bool numTASIsSet; 101 private uint _numTAS; 102 /// <summary> 103 /// The number of spins test-and-set mutexes should execute before 104 /// blocking. 105 /// </summary> 106 public uint NumTestAndSetSpins { 107 get { return _numTAS; } 108 set { 109 numTASIsSet = true; 110 _numTAS = value; 111 } 112 } 113 114 115 } 116} 117