Connection pools


Connection pools are implemented in the io.pools vocabulary. They are used to reuse sockets and connections which may be potentially expensive to create and destroy.

The class of connection pools:
pool


Creating connection pools:
<pool> ( class -- pool )


A utility combinator:
with-pool ( pool quot -- )


Acquiring and returning connections, and a utility combinator:
acquire-connection ( pool -- conn )

return-connection ( conn pool -- )

with-pooled-connection ( pool quot -- )


Pools are not created directly, instead one uses subclasses which implement a generic word:
make-connection ( pool -- conn )


One example is a datagram socket pool:
datagram-pool

<datagram-pool> ( addrspec -- pool )