Hi

  Transaction "read point" is changed every time when transaction is
started or retried.So the result is all right.If you want the ref1 cloud
not be modified by other transactions ,you can use "ensure":

(defn deref-delay-deref [ref1 ref2 delay]
        (.start
           (Thread.
              #((println "READ start")
                (dosync
                 (println "transaction starting")
                * (ensure ref1)*
                  (let [a @ref2]
                     (Thread/sleep delay)
                     (println "S r1=" @ref1))) ; should be consistent with
@ref2
                (println "READ end")))))

2012/4/17 Herwig Hochleitner <hhochleit...@gmail.com>

> > So if you create 2 refs and then read them in a transaction they could be
> > inconsistent with each other. i.e they won't necessarily return the value
> > the ref had at the start of the transaction.
> >
> > However, if you give the refs some history by updating them in a prior
> > transaction, then the two refs will be consistent with each other in
> > subsequent transactions.
> >
> > This seems rather dangerous to me. Is there a rational for not creating
> at
> > least 1 history entry for a ref at ref creation time.
>
> I haven't looken into your examples in detail, but clojure has
> http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/ensure
> to get consistent reads.
>
> I don't know exactly why read skew is allowed by default. Maybe it's
> along the lines of: If reads were consistent by default, performance
> would suffer and write skew would still be possible (which can be
> prevented by (ref-set ref @ref))
>
> kind regards
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
>



-- 
庄晓丹
Email:        killme2...@gmail.com xzhu...@avos.com
Site:           http://fnil.net
Twitter:      @killme2008

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to