Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defn log
- "Print the message with current *name* as a label."
- [message]
- (println (str *name* ": " message)))
- (defmacro defthread
- "Define object flow in new thread and
- binds *name*."
- [thread-name & body]
- `(def ~thread-name
- (quote
- (binding [*name* ~(name thread-name)]
- (future ~@body)))))
- (defn begin
- "First message in thread."
- [message]
- (log (str message " ●")))
- (defn end
- "Last message in thread."
- [message]
- (log (str message ". ○")))
- (defthread client
- (begin "Pay")
- (>!! m1 1)
- (log "Wait for cheque")
- (<!! m2)
- (log "Get cheque")
- (log "Give cheque to reception")
- (>!! s1 1)
- (log "Wait for goods and warranty")
- (<!! m7)
- (end "Get goods and warranty"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement