You can check with `(clojure.lang.LockingTransaction/isRunning)` (the io! 
macro does this) but I'm not sure if it's considered a public API.

https://github.com/clojure/clojure/blob/f6a90ff2931cec35cca0ca7cf7afe90ab99e3161/src/clj/clojure/core.clj#L2390

On Wednesday, 15 July 2015 13:53:11 UTC+1, Ragnar Dahlén wrote:
>
> Hi Bill,
>
> You are correct in that this involves close integration with the STM. The 
> agent implementation is aware of transactions and if a transaction is 
> running when dispatching an action, it will be enqneued in a special agent 
> action queue that STM implementation respects.
>
> AFAIK there is no public API for checking if a transaction is currently 
> running.
>
> See:
>
> https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Agent.java#L249
>
> https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/LockingTransaction.java#L106
>
>
>
>
>
>
> On Wednesday, 15 July 2015 13:26:11 UTC+1, William la Forge wrote:
>>
>> On this page http://clojure.org/agents I read the following:
>>      "Agents are integrated with the STM - any dispatches made in a 
>> transaction are held until it commits, and are discarded if it is retried 
>> or aborted."
>>
>> So there must be a way to tell if a dispatch is made from within a 
>> transaction. Yet I am looking here http://clojure.org/refs and can not 
>> find any such function.
>>
>> What then is the means of determining if you are processing a 
>> transaction, or is this something that involves close integration with STM?
>>
>> thanks! --Bill
>>
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
[email protected]
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 unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to