Object pool pattern: Difference between revisions

Content deleted Content added
Implementation: added link to Smart Pointer
m Rm "IVSR" references added by an IP that add nothing to the code
Line 72:
 
== Examples ==
 
=== C# ===
In the .NET [[Base Class Library]] there are a few objects that implement this pattern. <code>System.Threading.ThreadPool</code> is configured to have a predefined number of threads to allocate. When the threads are returned, they are available for another computation. Thus, one can use threads without paying the cost of creation and disposal of threads.
Line 78 ⟶ 77:
The following shows the basic code of the object pool design pattern implemented using C#. For brevity the properties of the classes are declared using C# 3.0 automatically implemented property syntax. These could be replaced with full property definitions for earlier versions of the language. Pool is shown as a static class, as it's unusual for multiple pools to be required. However, it's equally acceptable to use instance classes for object pools.
<source lang="csharp">
namespace IVSR.DesignPatern.Objectpool
//IVSR: ObjectPool Design pattern
namespace IVSR.DesignPatern.Objectpool
{
// The PooledObject class is the type that is expensive or slow to instantiate,