Anonymous user
Synchronous concurrency: Difference between revisions
changed lang tag for Clojure
(changed lang tag for Clojure) |
|||
Line 160:
The ''state'' argument is the agent's state at the start of the call, and the last expression becomes the agent's new state.
<lang
(def writer (agent 0))
Line 170:
The reader executes on the main thread. It passes each line to the writer -- the ''send'' call returns immediately, waits until the writer has finished writing all the lines, gets the line count & prints it, and terminates the writer.
<lang
(send writer write-line line))
(await writer)
|