return rp;
}
+static void
+rp_free(struct respool *rp)
+{
+ if (!rp->mpool)
+ xfree(rp);
+ if (rp_current() == rp)
+ rp_switch(NULL);
+}
+
void
rp_delete(struct respool *rp)
{
ASSERT(r->rpool == rp);
res_free(r);
}
- if (!rp->mpool)
- xfree(rp);
- if (rp_current() == rp)
- rp_switch(NULL);
+ rp_free(rp);
+}
+
+void
+rp_detach(struct respool *rp)
+{
+ struct resource *r;
+ while (r = clist_head(&rp->resources))
+ {
+ ASSERT(r->rpool == rp);
+ res_detach(r);
+ }
+ rp_free(rp);
}
void
* - check other candidates for resourcification
* - respool as a resource in another respool?
* - unit tests
+ * - automatic freeing of trans pool on thread exit
*/
#ifndef _UCW_RESPOOL_H
struct respool *rp_new(const char *name, struct mempool *mp);
void rp_delete(struct respool *rp);
+void rp_detach(struct respool *rp);
void rp_dump(struct respool *rp);
static inline struct respool *