mailbox-threads weirdness added by megane on Tue Oct 16 19:28:42 2012
(use mailbox-threads) (define (new-t prev i) (let [(t (make-thread (lambda () (let lp [] (thread-receive) (thread-send prev i) (lp))) i))] (thread-start! t) t)) (let* [(p (current-thread)) (n 500) ; <-- increase this number if everything works (threads (map (lambda [i] (new-t p i)) (iota n)))] (for-each (lambda (t) (thread-send t 1)) threads) (let lp [(i 1)] (print i " " (thread-receive)) (if (< i n) (lp (add1 i))))) ;; The send by the first thread got borked ;; Warning (#<thread: 0>): in thread: (mailbox-send!) bad argument type - not a mailbox: (mboxthread () #<mailbox mbox-thread queued = 0 waiters = 0> #<mailbox-cursor ma............>... ;; Call history: ;; mailbox-threads.scm:93: thread-mbox ;; mailbox-threads.scm:88: thread? ;; mailbox-threads.scm:36: thread? ;; mailbox-threads.scm:37: thread-specific ;; mailbox-threads.scm:89: add-specifics! ;; mailbox-threads.scm:51: mailbox#make-mailbox ;; mailbox-threads.scm:52: mailbox#make-mailbox-cursor ;; mailbox-threads.scm:54: thread-specific-set! ;; mailbox-threads.scm:93: mailbox#mailbox-send! ;; type-errors.scm:115: make-error-type-message ;; type-errors.scm:103: make-bad-argument-message ;; type-errors.scm:105: make-type-name-message ;; type-errors.scm:98: ->string ;; type-errors.scm:99: conc ;; type-errors.scm:102: string-append ;; type-errors.scm:115: signal-type-error <--