-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Mark Lauter edited this page Jun 15, 2026
·
3 revisions
IPool<TPoolItem> is a thread-safe object pool for expensive-to-create, reusable instances — connections, clients, sockets. It hands items out under a lease, takes them back on release, and caps how many exist at once. That cap is a hard ceiling, so the pool doubles as a concurrency throttle.
Pool ships as the MSL.Pool NuGet package and targets .NET 10.
- New to Pool? Install it and lease your first item — start with Installation, then the Quickstart.
- Building against it? The guides walk through each capability: Leasing and releasing, Item factories, Preparation strategies, Named pools, and an end-to-end SMTP connection pool recipe. Read Avoiding footguns before you ship.
- Looking something up? The reference covers the IPool API, Pool options, Dependency injection extensions, and Metrics.
- Curious how it works inside? How leasing works traces a single lease; The capacity gate explains the
SemaphoreSlimdesign.
Reach for Pool when an object is expensive to create and safe to reuse, and you want a hard ceiling on how many exist at once:
- Connection pools — SMTP, database, or any long-lived network connection
- Clients that hold a socket or session and cost real time to construct
- Bounded concurrency —
MaxSizecaps concurrent leases, so the pool throttles load - Items that idle out — a connection the server drops after inactivity, re-checked on each lease
Skip Pool when the object is cheap to construct — allocate it directly. For stateless reset-and-reuse objects with no async readiness step, Microsoft.Extensions.ObjectPool is lighter. For HttpClient, use IHttpClientFactory.