Skip to content

Commit 306efa5

Browse files
committed
Code cleanup
1 parent eb423fd commit 306efa5

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/DbConnectionPool.cs

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99
using System.Diagnostics;
1010
using System.Diagnostics.CodeAnalysis;
1111
using System.Runtime.CompilerServices;
12-
using System.Runtime.ConstrainedExecution;
13-
using System.Runtime.InteropServices;
1412
using System.Runtime.Versioning;
1513
using System.Threading;
1614
using System.Threading.Tasks;
@@ -362,17 +360,17 @@ internal WaitHandle[] GetHandles(bool withCreate)
362360
}
363361
}
364362

365-
private const int MAX_Q_SIZE = (int)0x00100000;
363+
private const int MAX_Q_SIZE = 0x00100000;
366364

367365
// The order of these is important; we want the WaitAny call to be signaled
368366
// for a free object before a creation signal. Only the index first signaled
369367
// object is returned from the WaitAny call.
370-
private const int SEMAPHORE_HANDLE = (int)0x0;
371-
private const int ERROR_HANDLE = (int)0x1;
372-
private const int CREATION_HANDLE = (int)0x2;
373-
private const int BOGUS_HANDLE = (int)0x3;
368+
private const int SEMAPHORE_HANDLE = 0x0;
369+
private const int ERROR_HANDLE = 0x1;
370+
private const int CREATION_HANDLE = 0x2;
371+
private const int BOGUS_HANDLE = 0x3;
374372

375-
private const int WAIT_ABANDONED = (int)0x80;
373+
private const int WAIT_ABANDONED = 0x80;
376374

377375
private const int ERROR_WAIT_DEFAULT = 5 * 1000; // 5 seconds
378376

@@ -511,7 +509,7 @@ private bool NeedToReplenish
511509
if (totalObjects < MinPoolSize)
512510
return true;
513511

514-
int freeObjects = (_stackNew.Count + _stackOld.Count);
512+
int freeObjects = _stackNew.Count + _stackOld.Count;
515513
int waitingRequests = _waitCount;
516514
bool needToReplenish = (freeObjects < waitingRequests) || ((freeObjects == waitingRequests) && (totalObjects > 1));
517515

@@ -606,7 +604,7 @@ private void CleanupCallback(object state)
606604

607605
// Destroy free objects that put us above MinPoolSize from old stack.
608606
while (Count > MinPoolSize)
609-
{
607+
{
610608
// While above MinPoolSize...
611609
if (_waitHandles.PoolSemaphore.WaitOne(0, false))
612610
{
@@ -1429,17 +1427,17 @@ private bool TryGetConnection(DbConnection owningObject, uint waitForMultipleObj
14291427
}
14301428
break;
14311429

1432-
case (WAIT_ABANDONED + SEMAPHORE_HANDLE):
1430+
case WAIT_ABANDONED + SEMAPHORE_HANDLE:
14331431
SqlClientEventSource.Log.TryPoolerTraceEvent("<prov.DbConnectionPool.GetConnection|RES|CPOOL> {0}, Semaphore handle abandonded.", ObjectID);
14341432
Interlocked.Decrement(ref _waitCount);
14351433
throw new AbandonedMutexException(SEMAPHORE_HANDLE, _waitHandles.PoolSemaphore);
14361434

1437-
case (WAIT_ABANDONED + ERROR_HANDLE):
1435+
case WAIT_ABANDONED + ERROR_HANDLE:
14381436
SqlClientEventSource.Log.TryPoolerTraceEvent("<prov.DbConnectionPool.GetConnection|RES|CPOOL> {0}, Error handle abandonded.", ObjectID);
14391437
Interlocked.Decrement(ref _waitCount);
14401438
throw new AbandonedMutexException(ERROR_HANDLE, _waitHandles.ErrorEvent);
14411439

1442-
case (WAIT_ABANDONED + CREATION_HANDLE):
1440+
case WAIT_ABANDONED + CREATION_HANDLE:
14431441
SqlClientEventSource.Log.TryPoolerTraceEvent("<prov.DbConnectionPool.GetConnection|RES|CPOOL> {0}, Creation handle abandoned.", ObjectID);
14441442
Interlocked.Decrement(ref _waitCount);
14451443
throw new AbandonedMutexException(CREATION_HANDLE, _waitHandles.CreationSemaphore);
@@ -1561,7 +1559,7 @@ private DbConnectionInternal GetFromGeneralPool()
15611559
PerformanceCounters.NumberOfFreeConnections.Decrement();
15621560
#endif
15631561
}
1564-
return (obj);
1562+
return obj;
15651563
}
15661564

15671565
private DbConnectionInternal GetFromTransactedPool(out Transaction transaction)

src/Microsoft.Data.SqlClient/src/Microsoft/Data/ProviderBase/IDbConnectionPool.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ internal int ObjectID
2424
}
2525
}
2626

27+
#region Abstract Properties
2728
internal abstract int Count
2829
{
2930
get;
@@ -84,7 +85,9 @@ internal abstract bool UseLoadBalancing
8485
{
8586
get;
8687
}
88+
#endregion
8789

90+
#region Abstract Methods
8891
internal abstract void Clear();
8992

9093
internal abstract void DestroyObject(DbConnectionInternal obj);
@@ -104,7 +107,6 @@ internal abstract bool UseLoadBalancing
104107
internal abstract void Shutdown();
105108

106109
internal abstract void TransactionEnded(Transaction transaction, DbConnectionInternal transactedObject);
107-
108-
110+
#endregion
109111
}
110112
}

0 commit comments

Comments
 (0)