Chapter    7

The Object Pool Pattern

The object pool pattern is a variation on the singleton pattern that provides access to multiple identical objects rather than a single instance. This is useful when you have objects that represent a set of fungible resources, each of which can be used by only one component at a time. In this chapter, I describe the basic object pool pattern, and in Chapter 8 I show you some useful variations that allow object pools to adapt to different situations. Table 7-1 puts the object pool pattern in context.

Table 7-1. Putting the Object Pool Pattern into Context

Question

Answer

What is it?

The object pool pattern manages a collection of reusable objects that are provided to calling components. A component obtains an ...

Get Pro Design Patterns in Swift now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.