Permalink
Browse files

[fix] stdlib/transactions: workaround a serialisation limitation

  • Loading branch information...
1 parent cbe42b7 commit c6831a836cca875551366efd25190a1c5b9aaf07 Louis Gesbert committed Jul 19, 2011
Showing with 9 additions and 8 deletions.
  1. +9 −8 stdlib/core/db/db.opa
View
@@ -252,11 +252,14 @@ Db = {{
`<-` = Db.`<-`
-type transaction = {{
+/* ideally, we don't want the 'a parameter, and try should be a type-forall('a).
+ However, at the time being functions with types-forall can't be poperly
+ serialised: count this as a temporary workaround */
+type transaction('a) = {
/** Calls a function within the transaction. On error, the execution is
skipped (the error status can be checked by calls to [try] or [commit]) */
- in: (-> {}) -> {};
+ in: (-> void) -> void;
/** [try(f,fallback)] applies function [f] within the transaction,
triggering [fallback] in case of problem */
@@ -270,7 +273,7 @@ type transaction = {{
the error case, any further calls to [in] will be ignored */
rollback: -> void;
-}}
+}
/* Implementation note:
@@ -280,14 +283,12 @@ type transaction = {{
*/
Transaction = {{
- @private Make(tr : opa_transaction_t) : transaction = {{
- in(f) = try(f, -> void)
- /** [try(tr,f,fallback)] applies function [f] within the transaction [tr],
- triggering [fallback] in case of problem */
+ @private @server_private Make(tr : opa_transaction_t) : transaction = {
+ in(f) = %%opa_transaction_continue%%(tr,f, (-> void))
try = %%opa_transaction_continue%%(tr,_,_)
commit() = %%opa_transaction_commit%%(tr)
rollback() = %%opa_transaction_abort%%(tr)
- }}
+ }
/** Start a new, empty transaction */
new() = Make(%%opa_transaction_start%%())

0 comments on commit c6831a8

Please sign in to comment.