Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / Net / System / Net / ConnectionPoolManager.cs / 1 / ConnectionPoolManager.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Net { using System; using System.Collections; using System.Diagnostics; using System.Security; using System.Security.Permissions; using System.Threading; using System.Globalization; internal class ConnectionPoolManager { private static Hashtable m_ConnectionPools = new Hashtable(); // Hashtable used for connection pools private static object s_InternalSyncObject; private ConnectionPoolManager() { } private static object InternalSyncObject { get { if (s_InternalSyncObject == null) { object o = new Object(); Interlocked.CompareExchange(ref s_InternalSyncObject, o, null); } return s_InternalSyncObject; } } /*internal static ConnectionPool[] ConnectionPools { get { lock(InternalSyncObject) { ConnectionPool [] connectionPools = new ConnectionPool[m_ConnectionPools.Count]; m_ConnectionPools.CopyTo(connectionPools, 0); return connectionPools; } } } */ private static string GenerateKey(string hostName, int port, string groupName) { return hostName+"\r"+port.ToString(NumberFormatInfo.InvariantInfo)+"\r"+groupName; } internal static ConnectionPool GetConnectionPool(ServicePoint servicePoint, string groupName, CreateConnectionDelegate createConnectionCallback) { string key = GenerateKey(servicePoint.Host, servicePoint.Port, groupName); lock(InternalSyncObject) { ConnectionPool connectionPool = (ConnectionPool) m_ConnectionPools[key]; if (connectionPool == null) { connectionPool = new ConnectionPool(servicePoint, servicePoint.ConnectionLimit, 0, servicePoint.MaxIdleTime, createConnectionCallback); m_ConnectionPools[key] = connectionPool; } return connectionPool; } } /* internal static ConnectionPool GetConnectionPool(string hostName, int port, string groupName, CreateConnectionDelegate createConnectionCallback) { string key = hostName + "\r" + port.ToString(NumberFormatInfo.InvariantInfo) + "\r" + groupName; lock(InternalSyncObject) { ConnectionPool connectionPool = (ConnectionPool) m_ConnectionPools[key]; if (connectionPool == null) { ServicePoint servicePoint = ServicePointManager.FindServicePoint(new Uri("sockets://" + hostName + ":" + port.ToString(NumberFormatInfo.InvariantInfo)), null); connectionPool = new ConnectionPool(servicePoint, m_DefaultMaxPool, 0, servicePoint.MaxIdleTime, createConnectionCallback); m_ConnectionPools[key] = connectionPool; } return connectionPool; } } */ internal static bool RemoveConnectionPool(ServicePoint servicePoint, string groupName) { string key = GenerateKey(servicePoint.Host, servicePoint.Port, groupName); lock(InternalSyncObject) { ConnectionPool connectionPool = (ConnectionPool)(m_ConnectionPools[key]); if(connectionPool != null) { m_ConnectionPools[key] = null; m_ConnectionPools.Remove(key); return true; } } return false; } } }
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- HttpAsyncResult.cs
- Config.cs
- KnownColorTable.cs
- ThicknessAnimationBase.cs
- TablePattern.cs
- ActivityExecutorSurrogate.cs
- DiscoveryInnerClientManaged11.cs
- OLEDB_Util.cs
- HttpServerVarsCollection.cs
- Set.cs
- ProfileParameter.cs
- DSASignatureFormatter.cs
- SourceSwitch.cs
- TokenizerHelper.cs
- CodeAssignStatement.cs
- ISCIIEncoding.cs
- Int64Storage.cs
- XmlTextReader.cs
- RemotingException.cs
- StringDictionary.cs
- TargetParameterCountException.cs
- WebServiceParameterData.cs
- TagMapCollection.cs
- XmlObjectSerializer.cs
- HandleCollector.cs
- ImpersonateTokenRef.cs
- ValueSerializerAttribute.cs
- CacheHelper.cs
- DispatcherHookEventArgs.cs
- HashCryptoHandle.cs
- ReflectionServiceProvider.cs
- RenderContext.cs
- DateTimeFormatInfoScanner.cs
- Propagator.Evaluator.cs
- ByteStack.cs
- Application.cs
- SqlCacheDependencySection.cs
- SocketConnection.cs
- ControlUtil.cs
- WebPartConnectionCollection.cs
- EventMappingSettings.cs
- PageWrapper.cs
- RelationshipManager.cs
- ReadingWritingEntityEventArgs.cs
- ToolStripItem.cs
- PathSegmentCollection.cs
- ContextItem.cs
- TextEncodedRawTextWriter.cs
- RequestTimeoutManager.cs
- EventHandlerList.cs
- CheckBoxPopupAdapter.cs
- LabelTarget.cs
- ImplicitInputBrush.cs
- XmlRootAttribute.cs
- CompoundFileStorageReference.cs
- DataGridViewLayoutData.cs
- EndpointNotFoundException.cs
- NgenServicingAttributes.cs
- SqlDataSourceWizardForm.cs
- UnauthorizedAccessException.cs
- ArrayConverter.cs
- BuilderPropertyEntry.cs
- RepeaterCommandEventArgs.cs
- CompilationLock.cs
- ProcessProtocolHandler.cs
- Page.cs
- PropertyRecord.cs
- SetterBaseCollection.cs
- x509utils.cs
- _LocalDataStore.cs
- HtmlGenericControl.cs
- PrivilegeNotHeldException.cs
- WindowsGraphics.cs
- rsa.cs
- ConsoleTraceListener.cs
- DataSysAttribute.cs
- JapaneseCalendar.cs
- MsmqIntegrationAppDomainProtocolHandler.cs
- DbParameterHelper.cs
- X509ChainPolicy.cs
- ComponentRenameEvent.cs
- AuthenticationServiceManager.cs
- ActivityExecutionFilter.cs
- ActivityValidationServices.cs
- UpdatableGenericsFeature.cs
- XPathExpr.cs
- RsaKeyIdentifierClause.cs
- OleDbCommandBuilder.cs
- VisualBrush.cs
- KernelTypeValidation.cs
- CompressionTransform.cs
- FilterEventArgs.cs
- LinkArea.cs
- CodeCatchClauseCollection.cs
- DataGridViewSelectedCellCollection.cs
- infer.cs
- SqlClientMetaDataCollectionNames.cs
- SoapIncludeAttribute.cs
- GridItemProviderWrapper.cs
- OdbcRowUpdatingEvent.cs