BaseObjectPool Class
From RemObjects Software
This is a Data Abstract Architecture entry
Feel free to add your notes to this topic below.
Overview (.NET)
Base class for all object pooling classes, provides methods to Acquire and Release elements from the thread pool; sub classes implement the abstract method to create a new instance.
This object pool uses the Activator class to create a new instance.
Namespace
Declaration (C#)
public abstract class BaseObjectPool<TItem> : IObjectPool<TItem>, IDisposable, IEnumerable, IEnumerator where TItem: class;
Hierarchy
- RemObjects.Common.Pooling.BaseObjectPool
Properties
| | | |
|---|---|---|
| AcquiredInstancesCount | Integer | Contains the number of acquired items from the object pool. |
| Behavior | PoolBehavior | Specifies the behavior of the object pool when an item is going to be acquired but the pool is full (the elements in the pool are equal to MaxPoolSize).
By default this is set to PoolBehavior. Wait, which will wait until a new item becomes available before returning the item. IgnoreAndReturn will return a new instance if a pooled item isn't available. RaiseError will throw an exception if an item is not available from the pool. |
| MaxPoolSize | Integer | The maximum number of items to be contained in the pool of this object pool, or -1 for unlimited. |
| NonAcquiredInstancesCount | Integer | Contains the number of instances in the pool that have not been acquired. |
| PoolSize | Integer | Returns the size of the pool, including already acquired instances (NonAcquiredInstancesCount + AcquiredInstancesCount). |
| WaitTimeOut | Integer | Time that the object pool will wait to acquire a new instance before throwing a timeout exception when the Behavior is set to PoolBehavior.Wait.
When the value is -1 the pool will wait indefinitely. |
Methods
| | |
|---|---|
| AcquireInstance | Acquires an item from the pool.
If no items are available from the pool, Behavior property specifies whether the pool will wait for an item to become available, throw an exception or create a new, unpooled instance. |
| Clear | Clears all items from the pool.
This has the same effect as calling Resize(0, true). |
| ReleaseInstance | Releases an acquired item back into the pool.
When the pool is using the Waiting behavior, the first thread waiting will return after releasing an item to a full pool. |
| Resize | Resizes the pool.
If second parameter is true it will set the maximum size to first parameters's value. If second parameter is false and there are more acquired in the list than given in first parameters's value, this method will throw an exception. |
See Also
Product: RemObjects Data Abstract
Current version: Data Abstract 'Vinci' (5.0)
Lists — Glossary — Features — How To — Drivers — Components — Tools — Samples — Articles — Architecture — Issues
Categories: Text | Data Abstract | Architecture | Class | .NET
