Hi,
im not sure how to solve the following problem:
(defn parse [outstream-agent xml]
(let [content (clojure.xml/parse (ByteArrayInputStream. (. xml
getBytes)))
first-element (:tag content) ]
(try
(if @*is-syncing*
(do
; iust continue f the agent is not
running
(await *message-cache-agent* )
(if @*is-syncing*
(let [command (first-element
*process-during-sync*)
cache (first-element
*cache-during-sync*)
]
(if command
(command
outstream-agent content)
(if cache
(cache-message content)
)
)
)
((first-element *messages*)
outstream-agent content)
)
)
((first-element *messages*) outstream-agent
content)
)
(catch Exception e
(do
(info (. e getMessage))
(fatal (str "Unknown command:" first-element))
false
)))))
The above code can be run by n threads. If the application is syncing
certain messages are going to be cached. At some point the messages in
the cache needed to be processed by a different thread (the *message-
cache-agent* in this example). After that *is-syncing* is false. The
problem with the above code is that messages could be added to the
cache after the message-cache-agent is started so that is possible
that some messages are not sent by the agent.
Right now I can only think of two solutions:
1.) the message-cache-agent checks for a certain amount of time if
there are now new messages
2.) I modify the code like this:
(if cache
(cache-message content)
(if (mesage-cache-agent-is-running)
(send-of *message-cache-agent* send-last-message-with
content))))
)
The question is.What would be the correct solution to this problem ?
Regards
Roger
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---