summaryrefslogtreecommitdiff
path: root/static/v10/man3/pool.3
diff options
context:
space:
mode:
authorJacob McDonnell <jacob@jacobmcdonnell.com>2026-04-25 21:07:28 -0400
committerJacob McDonnell <jacob@jacobmcdonnell.com>2026-04-25 21:07:28 -0400
commit711594636704defae873be1a355a292505585afd (patch)
tree59ee13f863830d8beba6cfd02bbe813dd486c26f /static/v10/man3/pool.3
parent3258a063c1f189d7b019e40e525b46bef9b9a7b1 (diff)
docs: Added UNIX V10 Manuals
Diffstat (limited to 'static/v10/man3/pool.3')
-rw-r--r--static/v10/man3/pool.385
1 files changed, 85 insertions, 0 deletions
diff --git a/static/v10/man3/pool.3 b/static/v10/man3/pool.3
new file mode 100644
index 00000000..10224c10
--- /dev/null
+++ b/static/v10/man3/pool.3
@@ -0,0 +1,85 @@
+.TH POOL 3+
+.CT 2 datatype
+.SH NAME
+pool \- fast memory allocation
+.SH SYNOPSIS
+.nf
+.B #include <Pool.h>
+.PP
+.ft L
+struct Pool {
+ Pool(unsigned);
+ ~Pool();
+ void* alloc();
+ void free(void*)
+};
+.fi
+.SH DESCRIPTION
+.PP
+Every
+.L Pool
+is a collection of
+.IR elements ,
+each of which is an array of bytes.
+All elements of a pool
+are the same size.
+Pool functions are
+.nr xx \w'\fIp\fL.free(\fIep\fL)\ '
+.TP \n(xxu
+.BI Pool( n )
+Construct a pool whose elements are of size
+.I n.
+.TP
+.IB p .alloc()
+Allocate a new element in pool
+.LR p .
+Return a pointer to the element.
+.TP
+.IB p .free( ep )
+Free the element of
+.I p
+pointed to by
+.I ep.
+The element must
+have been allocated from
+.I p.
+.PP
+Destroying a pool
+frees all the memory occupied by its elements.
+.PP
+The memory in a pool element is aligned on
+the same boundary as memory returned by
+.IR malloc (3)
+so that it may be used to contain an
+object of any type.
+In typical use, there would be one pool per class, with
+the pool known only to the
+.B new
+and
+.B delete
+operators of that class.
+.SS Performance
+Pool memory is allocated in chunks that are typically
+about 1,000 bytes each.
+Once a chunk is allocated to a particular pool,
+that chunk is only released when the pool itself
+is destroyed.
+.PP
+Elements are allocated inline except when
+a new chunk must be added to the pool.
+Elements are always freed inline.
+.SH EXAMPLES
+.B #include <Pool.h>
+.PP
+.EX
+struct Mytype {
+ static Pool mypool;
+ // constructors and members
+ void* operator new(unsigned) { return mypool.alloc(); }
+ void operator delete(void* p) { mypool.free(p); }
+};
+.EE
+.PP
+.B Pool Mytype::mypool(sizeof(Mytype));
+.SH SEE ALSO
+.IR malloc (3)