質問

In the Rich Hickey Code here he wraps his Clojure Ants code in a sync function (when one would idiomatically expect dosync).

When we look at the doco for sync here, we see

Same as dosync but allows for extra options (which are not currently supported). Probably best to use dosync instead at the moment.

My question is - what are the extra transaction flags intended (or even possible) for the dosync operator? Is it like database transaction isolation levels, where you have different settings like read-committed etc.

役に立ちましたか?

解決

There are no possible flags that will have any effect. The macro declaration for sync is:

 (defmacro sync 
   [flags-ignored-for-now & body]
   `(. clojure.lang.LockingTransaction
       (runInTransaction (fn [] ~@body)))) 

So you can put anything you would like there ;-) This is used in the ants demo because when that demo was written the language was evolving and it was thought that some flags would be needed, which turned out not to be the case.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top