View source code
Display the source code in dmd/root/rmem.d from which this
page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a
Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
local clone.
Struct dmd.root.rmem.Pool
Defines a pool for class objects. Objects can be fetched from the pool with make() and returned to the pool with dispose(). Using a reference that has been dispose()d has undefined behavior. make() may return memory that has been previously dispose()d.
struct Pool(T)
if (is(T == class));
Currently the pool has effect only if the GC is NOT used (i.e. either version(GC)
or mem
is false).
Otherwise make
just forwards to new
and dispose
does nothing.
Internally the implementation uses a singly-linked freelist with a global root. The "next" pointer is stored in the first word of each disposed object.
Fields
Name | Type | Description |
---|---|---|
root
|
T | The freelist's root |
Methods
Name | Description |
---|---|
dispose
(goner)
|
Signals to the pool that this object is no longer used, so it can recycle its memory. |
make
(args)
|
Returns a reference to a new object in the same state as if created with new T(args). |
Authors
Walter Bright, http://www.digitalmars.com
License
Copyright © 1999-2022 by the D Language Foundation | Page generated by ddox.