Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Transaction library

Moderators: kris

Posted: 05/22/07 21:14:19

I am interested in seeing transaction support added to Tango. This is something I would be willing to do some work on. Anyone have any thoughts on this? Is it an appropriate addition? Any opinions about what such a thing should look like? Where in the Tango hierarchy it should live?

TimK.

Author Message

Posted: 05/24/07 18:41:33

What kind of transactions? Transactional memory? Database transactions?

Posted: 05/25/07 07:25:50

Database-style transactions -- a single unit of work that encompasses state changes to more than one object.

My ultimate goal is to be able to do something like this:

void foo(BankAccount vendor, BankAccount buyer, uint amount)
{
    Transaction(vendor, buyer);
    buyer.debit(amount);
    vendor.credit(amount);
    Transaction.commit();
}

The ideal case would be that a minimal amount of boilerplate code would have to be added to BankAccount in order to make it support this. You can do this now -- D even has some really nice primitives for it -- but I'd like to make it simpler.

Posted: 05/26/07 15:19:34

Oh okay. This is basically what transactional memory is for. I suppose a similar technique could be used for transactions in a single-threaded application without all the fancy synchronized ops as well. I believe someone is actually working on a transactional memory lib, but as they haven't announced it yet I won't say more than that. I think the alternative would be to require each transaction object to expose a .clone() or .dup() method, which is called when the transaction is initialized.

Posted: 05/28/07 20:39:44

I'd like to see some prototypes for how this might work ... do you have something working, MrTact??

Posted: 06/11/07 19:56:40

Not yet. Reading about scope(exit) got my juices flowing and it occurred to me that it would be engaging to see how feasible this was. I haven't really invested any serious time in it yet . . . wanted to see whether it piqued anyone else's curiosity first.