Skip to content

Multi thread app works with interpreter But not working with jpm build #1256

Answered by bakpakin
Geo-7 asked this question in Q&A
Discussion options

You must be logged in to vote

The issue is the top level threaded channel, which is not marshaled correctly.

Fixed in cd36f1e

The immediate solution is to create the channel in main and pass to the producer and consumer.

(defn producer [conn-chan no]
  (forever
    (ev/sleep 5)
    (print "Adding data from producer num:" no)
    (ev/give conn-chan (math/random))))

(defn consumer [conn-chan no]
  (forever
    (ev/sleep 0.5)
    (def num (ev/take conn-chan))
    (print num ": Printing from consumer:" no)))

(defn main [& args]
  (def conn-chan (ev/thread-chan 1000))
  (ev/spawn-thread (producer conn-chan 1))
  (ev/spawn-thread (consumer conn-chan 1))
  (ev/spawn-thread (consumer conn-chan 2))
  (ev/sleep 20)
  (print "e…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@Geo-7
Comment options

@Geo-7
Comment options

@bakpakin
Comment options

Answer selected by Geo-7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants