C# Class System.Net.ConnectionPool

Show file Open project: gbarnett/shared-source-cli-2.0 Class Usage Examples

Private Properties

Property Type Description
Abort void
AsyncThread void
CancelErrorCallback void
CancelErrorCallbackWrapper void
CleanupCallback void
CleanupCallbackWrapper void
ConnectionPool System
Create PooledStream
Destroy void
Get PooledStream
GetConnection PooledStream
GetFromPool PooledStream
Initialize void
PutConnection void
PutNew void
QueueRequest void
ReclaimEmancipatedObjects bool
UserCreateRequest PooledStream

Private Methods

Method Description
Abort ( ) : void
AsyncThread ( ) : void

Processes async queued requests that are blocked on needing a free pooled stream works as follows: 1. while there are blocked requests, take one out of the queue 2. Wait for a free connection, when one becomes avail, then notify the request that its there 3. repeat 1 until there are no more queued requests 4. if there are no more requests waiting to for a free stream, then close down this thread

CancelErrorCallback ( ) : void

Called on error, after we waited a set amount of time from aborting

CancelErrorCallbackWrapper ( TimerThread timer, int timeNoticed, object context ) : void
CleanupCallback ( ) : void

This is called by a timer, to check for needed cleanup of idle pooled streams

CleanupCallbackWrapper ( TimerThread timer, int timeNoticed, object context ) : void
ConnectionPool ( ServicePoint servicePoint, int maxPoolSize, int minPoolSize, int idleTimeout, CreateConnectionDelegate createConnectionCallback ) : System

Constructor - binds pool with a servicePoint and sets up a cleanup Timer to nuke Idle Connections

Create ( CreateConnectionDelegate createConnectionCallback ) : PooledStream

Creates a new PooledStream, performs checks as well on the new stream

Destroy ( PooledStream pooledStream ) : void

Destroys a pooled stream from the pool

Get ( object owningObject, int result, bool &continueLoop, WaitHandle &waitHandles ) : PooledStream

Retrieves the pooled stream out of the pool, does this by using the result of a WaitAny as input, and then based on whether it has a mutex, event, semaphore, or timeout decides what action to take

GetConnection ( object owningObject, GeneralAsyncDelegate asyncCallback, int creationTimeout ) : PooledStream
GetFromPool ( object owningObject ) : PooledStream

Retrieves a pooled stream from the pool proper this work by first attemting to find something in the pool on the New stack and then trying the Old stack if something is not there availble

Initialize ( ) : void

Internal init stuff, creates stacks, queue, wait handles etc

PutConnection ( PooledStream pooledStream, object owningObject, int creationTimeout ) : void
PutNew ( PooledStream pooledStream ) : void
QueueRequest ( AsyncConnectionPoolRequest asyncRequest ) : void

Queues a AsyncConnectionPoolRequest to our queue of requests needing a pooled stream. If an AsyncThread is not created, we create one, and let it process the queued items

ReclaimEmancipatedObjects ( ) : bool
UserCreateRequest ( ) : PooledStream