[cl-prevalence-devel] Keeping state during transactions

Leslie P. Polzer sky at viridian-project.de
Sat Sep 26 07:40:51 UTC 2009


Alexey Voznyuk wrote:

>     There is something wrong with this patch.
>
>     It seems it targets the old cl-prevalence release (cvs one), where
> serialization.lisp is not splitted yet. But it doesn't matter, I see the
> following problems there:
>        - the patch seems incomplete (I didn't find where *txn-state* is
> defined, there are only use cases)

The following hunks seem to be missing:

diff --git a/lib/src/cl-prevalence/src/package.lisp
b/lib/src/cl-prevalence/src/package.lisp
index 3b924e9..973e9ca 100644
--- a/lib/src/cl-prevalence/src/package.lisp
+++ b/lib/src/cl-prevalence/src/package.lisp
@@ -13,6 +13,7 @@
 (defpackage :s-serialization
   (:use :cl)
   (:export
+   #:*txn-state*
    #:serializable-slots
    #:serialize-xml #:serialize-sexp
    #:deserialize-xml #:deserialize-sexp
diff --git a/lib/src/cl-prevalence/src/prevalence.lisp
b/lib/src/cl-prevalence/src/prevalence.lisp
index 7d21e2a..acb51d8 100644
--- a/lib/src/cl-prevalence/src/prevalence.lisp
+++ b/lib/src/cl-prevalence/src/prevalence.lisp
@@ -213,7 +213,9 @@

 (defmethod log-transaction ((system prevalence-system) (transaction transaction))
   "Log transaction for system"
-  (let ((out (get-transaction-log-stream system)))
+  (let ((*txn-state* (make-hash-table))
+        (out (get-transaction-log-stream system)))
+    (declare (special *txn-state*))
     (funcall (get-serializer system) transaction out (get-serialization-state system))
     (terpri out)
     (finish-output out)))


>        - I didn't get what *txn-state* is for. All that it does is
> doubling 'known-object-id' / 'set-known-object' functions.

*txn-state* holds the transaction-specific state. The old model
only has transaction states via a system-global variable that
gets reset before every transaction. This new code moves this
state to *txn-state* and uses the system-global variable as a
true global state that does not get reset.

Does that make things clear?


>        - There are only xml serialization related fixes, nothing for sexp.

Sorry about that, it's missing indeed. One of the reasons it's not
merged in yet...


>     Please check my latest 20090926 cumulative patch where I only
> removed serialization state clearing on each transaction. There are some
> tests included.

I don't think this will suffice. Can your code handle cycles in
the object graph?

  Leslie

-- 
http://www.linkedin.com/in/polzer





More information about the Cl-prevalence-devel mailing list