Unfortunately:

"No guarantees are made about how frequently values change."

"Note that while the unit of time of the return value is a millisecond, the
granularity of the value depends on the underlying operating system and may
be larger."

(see System nanoTime, currentTimeMillis javadoc)

However it looks interesting, "(dosync (alter myref inc))" takes much longer
than timer granularity on my Windows. Also for "transaction B" to depend on
"transaction A" from another thread it usually need to read A results
first,so the effective interval is even longer. (and much longer for a web
application transactions for example)

This is not suitable for general case, but can be implemented to be run
under condition that any dependable transactions are split in time further
than OS timer granularity. The locking is unnecessary at all in that case.

But IMHO the cleaner approach is to somehow return global transaction id
from Clojure STM if it's possible.

On Fri, Dec 4, 2009 at 2:16 PM, John Harrop <jharrop...@gmail.com> wrote:

> On Fri, Dec 4, 2009 at 6:50 AM, Sergey Didenko 
> <sergey.dide...@gmail.com>wrote:
>
>> Without the global transaction counter another problem arises.
>>
>> Suppose transaction B depends on ( results of ) transaction A. And they
>> are executed from different threads. However they have the right order when
>> executing the first time.
>>
>> How to guarantee that the execution order is the same when transactions
>> are replayed?
>>
>
> Use System/currentTimeMillis as a component in the transaction ID, along
> with a thread-local component, perhaps.
>
> --
> 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<clojure%2bunsubscr...@googlegroups.com>
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
>

-- 
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