Boost logo

Boost :

Subject: Re: [boost] persistence library proposal (with prototypeimplementation)
From: Stefan Strasser (strasser_at_[hidden])
Date: 2009-08-10 15:31:00

Am Monday 10 August 2009 10:44:42 schrieb Vicente Botet Escriba:
> Please could you resume which are the main goals of the library?

the main goal is to be able to extend the lifetime of an object, simply by
using another smart pointer:

int main(){
        shared_ptr<A> shared(new A);
        db_ptr<A> db(new A);
} // "shared" is destroyed, "db" is saved to disk
(given that it is referenced somewhere)

I should have explained this more clearly in my first mail, before going into
transaction details, but atomic transactions are an essential part of this
kind of transparent persistence, because you don't want to end up with
corrupted objects on disk.

> Why do you need to use files to track the memory changes, why don't just
> memory?

the library is supposed to recover the database from application crashes.
to accomplish this, object instances and a transaction log must be saved to
disk, even if all objects in use are cached in memory.
see e.g.

> we are working on allowing the global_int to be declared just as an int,
> i.e. no need to inherit from a transactional object to participate in a
> transaction. Other improvements will concern the definition of any operator
> and the implicit conversion so we can write
> tx_global_int++;
> return tx_global_int;

how do you track changes of tx_global_int without any wrapper?
(or did you refer to two different solutions, a) declaring as an int, or b)
defining operators for an int-wrapper?)

> how this is written with your library?

it doesn't really apply because once a db_ptr is dereferenced the transaction
is working on a local copy of the object:

struct A{
        int mem;
        void do_something(){ ++mem; }
        db_ptr<A> a;

only if read-only access is requested the original object is passed to the
user, e.g.:

void do_something(shared<A const> a);
        db_ptr<A> a;
        cerr <<>mem;

what is the intended use of native_trans/transaction_object in your library?
is it:
struct A{
        native_trans<int> mem1;
        native_trans<int> mem2;
A a;

or is it:

struct A : transaction_object{
        int mem1;
        int mem2;
A a;


> I'm interested.

me too, do have an example which shows the final intended use of the library?
I've looked over some of the examples but they seem to be test cases with a
lot of library internals.
the example I quoted was from one of the papers on your website.

> Could you add the code to the vault?

I didn't know about the boost vault, here it is:

Boost list run by bdawes at, gregod at, cpdaniel at, john at