Hi,

On 12 Mai, 15:37, Michael Jaaka <michael.ja...@googlemail.com> wrote:

> I have atom, which is some structure (my hashmap).
>
> Now periodically some data are assoc to my hashmap with swap!
> (producer).
>
> Also there is a consumer of these added data, which takes the data (in
> fact it just re-organize my hashmap, to mark the fact that something
> was borrowed/taken).

You can attach a watch to your atom:
(add-watch your-atom ::consumer consumer-fn).

So whenever your atom is updated your consumer function
will be called. However you'll have to guard somehow against
infinite loops, when modifying your atom in the consumer-fn.
In fact, I don't even know, whether it is possible or advisable
to change the reference in the watch function. But it could be
used to trigger a CyclicBarrier or such to kick-off the consumer
on another thread.

Sincerely
Meikel

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