History

Updated AdoSecurityProvider to cache last known security context such that security system can initialize without database access.

ritchiecarroll committed 12 years ago

Commit d0046311 parent 1a8fe7514 files · +1042 −427Browse files

Showing the changes to Source/Libraries/GSF.Core/Threading/InterprocessReaderWriterLock.cs (1 of 14 files). Show all

Unified · Split

Source/Libraries/GSF.Core/Threading/InterprocessReaderWriterLock.cs+24−16
@@ -29,7 +29,7 @@ using System.Threading; · 28 unmodified lines
2929 namespace GSF.Threading
3030 {
3131 /// <summary>
32− /// Represents an interprocess reader/writer lock using <see cref="Semaphore"/> and <see cref="Mutex"/> native locking mechanisms.
32+ /// Represents an inter-process reader/writer lock using <see cref="Semaphore"/> and <see cref="Mutex"/> native locking mechanisms.
3333 /// </summary>
3434 public class InterprocessReaderWriterLock : IDisposable
3535 {
@@ -43,9 +43,9 @@ namespace GSF.Threading · 7 unmodified lines
4343 public const int DefaultMaximumConcurrentLocks = 10;
4444
4545 // Fields
46− private Mutex m_semaphoreLock; // Mutex used to synchronize access to Semaphore
47− private Semaphore m_concurrencyLock; // Semaphore used for reader/writer lock on consumer object
48− private readonly int m_maximumConcurrentLocks;
46+ private Mutex m_semaphoreLock; // Mutex used to synchronize access to Semaphore
47+ private Semaphore m_concurrencyLock; // Semaphore used for reader/writer lock on consumer object
48+ private readonly int m_maximumConcurrentLocks; // Maximum number of concurrent locks before waiting
4949 private bool m_disposed;
5050
5151 #endregion
@@ -56,7 +56,7 @@ namespace GSF.Threading · 4 unmodified lines
5656 /// Creates a new instance of the <see cref="InterprocessReaderWriterLock"/> associated with the specified
5757 /// <paramref name="name"/> that identifies a source object needing concurrency locking.
5858 /// </summary>
59− /// <param name="name">Identifiying name of source object needing concurrency locking (e.g., a path and file name).</param>
59+ /// <param name="name">Identifying name of source object needing concurrency locking (e.g., a path and file name).</param>
6060 public InterprocessReaderWriterLock(string name)
6161 : this(name, DefaultMaximumConcurrentLocks)
6262 {
@@ -66,7 +66,7 @@ namespace GSF.Threading · 3 unmodified lines
6666 /// Creates a new instance of the <see cref="InterprocessReaderWriterLock"/> associated with the specified
6767 /// <paramref name="name"/> that identifies a source object needing concurrency locking.
6868 /// </summary>
69− /// <param name="name">Identifiying name of source object needing concurrency locking (e.g., a path and file name).</param>
69+ /// <param name="name">Identifying name of source object needing concurrency locking (e.g., a path and file name).</param>
7070 /// <param name="maximumConcurrentLocks">Maximum concurrent reader locks to allow.</param>
7171 /// <remarks>
7272 /// If more reader locks are requested than the <paramref name="maximumConcurrentLocks"/>, excess reader locks will simply
@@ -128,12 +128,16 @@ namespace GSF.Threading · 55 unmodified lines
128128 if (disposing)
129129 {
130130 if ((object)m_concurrencyLock != null)
131+ {
131132 m_concurrencyLock.Close();
132− m_concurrencyLock = null;
133+ m_concurrencyLock = null;
134+ }
133135
134136 if ((object)m_semaphoreLock != null)
137+ {
135138 m_semaphoreLock.Close();
136− m_semaphoreLock = null;
139+ m_semaphoreLock = null;
140+ }
137141 }
138142 }
139143 finally
@@ -147,7 +151,7 @@ namespace GSF.Threading · 7 unmodified lines
147151 /// Tries to enter the lock in read mode.
148152 /// </summary>
149153 /// <remarks>
150− /// Upon successful aquistion of a read lock, use the <c>finally</c> block of a <c>try/finally</c> statement to call <see cref="ExitReadLock"/>.
154+ /// Upon successful acquisition of a read lock, use the <c>finally</c> block of a <c>try/finally</c> statement to call <see cref="ExitReadLock"/>.
151155 /// One <see cref="ExitReadLock"/> should be called for each <see cref="EnterReadLock"/> or <see cref="TryEnterReadLock"/>.
152156 /// </remarks>
153157 public void EnterReadLock()
@@ -159,7 +163,7 @@ namespace GSF.Threading · 5 unmodified lines
159163 /// Tries to enter the lock in write mode.
160164 /// </summary>
161165 /// <remarks>
162− /// Upon successful aquistion of a write lock, use the <c>finally</c> block of a <c>try/finally</c> statement to call <see cref="ExitWriteLock"/>.
166+ /// Upon successful acquisition of a write lock, use the <c>finally</c> block of a <c>try/finally</c> statement to call <see cref="ExitWriteLock"/>.
163167 /// One <see cref="ExitWriteLock"/> should be called for each <see cref="EnterWriteLock"/> or <see cref="TryEnterWriteLock"/>.
164168 /// </remarks>
165169 public void EnterWriteLock()
@@ -171,7 +175,7 @@ namespace GSF.Threading · 5 unmodified lines
171175 /// Exits read mode and returns the prior read lock count.
172176 /// </summary>
173177 /// <remarks>
174− /// Upon successful aquistion of a read lock, use the <c>finally</c> block of a <c>try/finally</c> statement to call <see cref="ExitReadLock"/>.
178+ /// Upon successful acquisition of a read lock, use the <c>finally</c> block of a <c>try/finally</c> statement to call <see cref="ExitReadLock"/>.
175179 /// One <see cref="ExitReadLock"/> should be called for each <see cref="EnterReadLock"/> or <see cref="TryEnterReadLock"/>.
176180 /// </remarks>
177181 public int ExitReadLock()
@@ -184,7 +188,7 @@ namespace GSF.Threading · 6 unmodified lines
184188 /// Exits write mode.
185189 /// </summary>
186190 /// <remarks>
187− /// Upon successful aquistion of a write lock, use the <c>finally</c> block of a <c>try/finally</c> statement to call <see cref="ExitWriteLock"/>.
191+ /// Upon successful acquisition of a write lock, use the <c>finally</c> block of a <c>try/finally</c> statement to call <see cref="ExitWriteLock"/>.
188192 /// One <see cref="ExitWriteLock"/> should be called for each <see cref="EnterWriteLock"/> or <see cref="TryEnterWriteLock"/>.
189193 /// </remarks>
190194 public void ExitWriteLock()
@@ -199,12 +203,12 @@ namespace GSF.Threading · 8 unmodified lines
199203 /// <param name="millisecondsTimeout">The number of milliseconds to wait, or -1 (<see cref="Timeout.Infinite"/>) to wait indefinitely.</param>
200204 /// <returns><c>true</c> if the calling thread entered read mode, otherwise, <c>false</c>.</returns>
201205 /// <remarks>
202− /// Upon successful aquistion of a read lock, use the <c>finally</c> block of a <c>try/finally</c> statement to call <see cref="ExitReadLock"/>.
206+ /// Upon successful acquisition of a read lock, use the <c>finally</c> block of a <c>try/finally</c> statement to call <see cref="ExitReadLock"/>.
203207 /// One <see cref="ExitReadLock"/> should be called for each <see cref="EnterReadLock"/> or <see cref="TryEnterReadLock"/>.
204208 /// </remarks>
205209 public bool TryEnterReadLock(int millisecondsTimeout)
206210 {
207− bool success = false;
211+ bool success;
208212
209213 try
210214 {
@@ -263,7 +267,9 @@ namespace GSF.Threading · 52 unmodified lines
263267 // The only way to get a semaphore slot count is to execute a successful wait and release.
264268 startTime = DateTime.UtcNow.Ticks;
265269
266− if (success = m_concurrencyLock.WaitOne(millisecondsTimeout))
270+ success = m_concurrencyLock.WaitOne(millisecondsTimeout);
271+
272+ if (success)
267273 {
268274 int count = m_concurrencyLock.Release();
269275 int adjustedTimeout = millisecondsTimeout;
@@ -282,7 +288,9 @@ namespace GSF.Threading · 12 unmodified lines
282288 if (adjustedTimeout < 0)
283289 adjustedTimeout = 0;
284290
285− if (success = m_concurrencyLock.WaitOne(adjustedTimeout))
291+ success = m_concurrencyLock.WaitOne(adjustedTimeout);
292+
293+ if (success)
286294 count = m_concurrencyLock.Release();
287295 }
288296 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t