Object pool pattern: Difference between revisions

Content deleted Content added
Arch4ngel (talk | contribs)
m Added example in C#.
Arch4ngel (talk | contribs)
m Moved the example more at the bottom of the page.
Line 10:
# Allocate a new object, thus increasing the size of the pool. Pools that do this usually allow you to set the [[high water mark]] (the maximum number of objects ever used).
# In a [[Thread (computer science)|multithreaded]] environment, a pool may block the client until another thread returns an object to the pool.
 
== C# Examples ==
 
In C#, there is a few objects that implement this pattern. System.Threading.ThreadPool is configured to have a predefined amount of threads to allocate. When the threads are returned they are prepared to be ready to be assigned to another process.
 
== Pitfalls ==
Line 22 ⟶ 18:
 
Inadequate resetting of objects may also cause an information leak. If an object contains confidential data (e.g. a user's credit card numbers) that isn't cleared before the object is passed to a new client, a malicious or buggy client may disclose the data to an unauthorized party.
 
== C# Examples ==
 
In C#, there is a few objects that implement this pattern. System.Threading.ThreadPool is configured to have a predefined amount of threads to allocate. When the threads are returned they are prepared to be ready to be assigned to another process.
 
 
==References==