2 * The UCW Library -- Transactions
4 * (c) 2008 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.
13 #include "ucw/clists.h"
14 #include "ucw/mempool.h"
22 struct mempool *mp; // If set, resources are allocated from the mempool, otherwise by xmalloc()
27 struct res_class *rclass;
28 void *priv; // Private to the class
33 void (*undo)(struct res *t);
34 void (*dump)(struct res *t);
37 struct respool *rp_new(void);
38 void rp_delete(struct respool *rp);
39 void rp_dump(struct respool *rp);
41 struct resource *res_alloc(struct respool *rp);
42 void res_fix(struct resource *r);
43 void res_undo(struct resource *r);
44 void res_dump(struct resource *r);
46 static inline struct resource *
47 res_new(struct respool *rp, struct res_class *rc, void *priv)
49 struct resource *r = res_alloc(rp);
59 struct mempool_state trans_pool_state;
60 struct respool res_pool;
64 void trans_init(void); // Called automatically on trans_open() if needed
65 void trans_cleanup(void); // Free memory occupied by the transaction system pools
67 struct trans *trans_open(void);
68 struct trans *trans_get_current(void);
69 void trans_commit(void);
70 void trans_rollback(void);
71 void trans_dump(void);