]> mj.ucw.cz Git - libucw.git/blobdiff - ucw/respool.h
Resources: Simplified use of fb_tie()
[libucw.git] / ucw / respool.h
index 39f310c121e2c3ee545697dcde8b86358a8958e4..9764f12948bb0c5a7dada6ddbe855f7e0e1efcbc 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *     The UCW Library -- Resource Pools
  *
- *     (c) 2008 Martin Mares <mj@ucw.cz>
+ *     (c) 2008--2011 Martin Mares <mj@ucw.cz>
  *
  *     This software may be freely distributed and used according to the terms
  *     of the GNU Lesser General Public License.
@@ -12,6 +12,7 @@
  *     - 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
@@ -31,6 +32,7 @@ struct resource {
   struct respool *rpool;
   const struct res_class *rclass;
   void *priv;                                          // Private to the class
+  // More data specific for the particular class can follow
 };
 
 struct res_class {
@@ -43,6 +45,7 @@ struct res_class {
 
 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 *
@@ -60,7 +63,7 @@ rp_switch(struct respool *rp)
   return orp;
 }
 
-struct resource *res_alloc(const struct res_class *rc);        // Returns NULL if there is no pool active
+struct resource *res_alloc(const struct res_class *rc) LIKE_MALLOC;    // Returns NULL if there is no pool active
 void res_drop(struct resource *r);
 void res_detach(struct resource *r);
 void res_free(struct resource *r);
@@ -82,8 +85,8 @@ res_new(const struct res_class *rc, void *priv)
 
 struct resource *res_for_fd(int fd);                   // Creates a resource that closes a given file descriptor
 
-void *res_malloc(size_t size, struct resource **ptr);  // Allocates memory and creates a resource for it
-void *res_malloc_zero(size_t size, struct resource **ptr);     // Allocates zero-initialized memory and creates a resource for it
+void *res_malloc(size_t size, struct resource **ptr) LIKE_MALLOC;      // Allocates memory and creates a resource for it
+void *res_malloc_zero(size_t size, struct resource **ptr) LIKE_MALLOC; // Allocates zero-initialized memory and creates a resource for it
 void *res_realloc(struct resource *res, size_t size);
 
 #endif