2 * The UCW Library -- Resources for Sub-pools
4 * (c) 2011 Martin Mares <mj@ucw.cz>
6 * This software may be freely distributed and used according to the terms
7 * of the GNU Lesser General Public License.
11 #include <ucw/resource.h>
16 subpool_res_free(struct resource *r)
18 struct respool *rp = r->priv;
19 rp->subpool_of = NULL;
24 subpool_res_detach(struct resource *r)
26 struct respool *rp = r->priv;
27 rp->subpool_of = NULL;
31 subpool_res_dump(struct resource *r, uint indent)
34 rp_dump(r->priv, indent);
37 static const struct res_class subpool_res_class = {
39 .dump = subpool_res_dump,
40 .detach = subpool_res_detach,
41 .free = subpool_res_free,
45 res_subpool(struct respool *rp)
47 ASSERT(!rp->subpool_of);
48 struct resource *r = res_new(&subpool_res_class, rp);
49 ASSERT(r->rpool != rp); // Avoid simple loops
58 struct respool *rp = rp_new("interior", NULL);
59 struct respool *rp2 = rp_new("exterior", NULL);