2007-06-11 21:36:57 +00:00
|
|
|
#include <stasis/transactional.h>
|
2007-05-25 18:21:09 +00:00
|
|
|
|
2007-05-25 22:01:44 +00:00
|
|
|
int main (int argc, char ** argv) {
|
2007-05-25 18:21:09 +00:00
|
|
|
|
|
|
|
Tinit();
|
2007-05-25 22:01:44 +00:00
|
|
|
|
|
|
|
// First transaction
|
|
|
|
|
2007-05-25 18:21:09 +00:00
|
|
|
int xid = Tbegin();
|
2007-05-25 22:01:44 +00:00
|
|
|
recordid rid = Talloc(xid, sizeof(int));
|
|
|
|
|
|
|
|
// The application is responsible for memory management.
|
|
|
|
// Tset() will copy i; it can be freed immediately after the call is made.
|
|
|
|
|
|
|
|
int i = 42;
|
|
|
|
Tset(xid, rid, &i);
|
|
|
|
Tcommit(xid);
|
|
|
|
|
2007-05-25 18:21:09 +00:00
|
|
|
int j;
|
2007-05-25 22:01:44 +00:00
|
|
|
|
2007-05-25 18:21:09 +00:00
|
|
|
xid = Tbegin();
|
|
|
|
Tread(xid, rid, &j); // j is now 42.
|
2007-05-25 22:01:44 +00:00
|
|
|
Tdealloc(xid, rid);
|
|
|
|
Tabort(xid);
|
|
|
|
|
2007-05-25 18:21:09 +00:00
|
|
|
Tdeinit();
|
|
|
|
}
|