(defstruct thread nil suspended cont (:method resume (self) [self.cont]) (:method give (self item) [self.cont item]) (:method get (self) (yield-from run nil)) (:method start (self) (set self.cont (obtain self.(run))) (unless self.suspended self.(resume))) (:postinit (self) self.(start))) (defstruct consumer thread (count 0) (:method run (self) (whilet ((item self.(get))) (prinl item) (inc self.count)))) (defstruct producer thread consumer (:method run (self) (whilet ((line (get-line))) self.consumer.(give line)))) (let* ((con (new consumer)) (pro (new producer suspended t consumer con))) pro.(resume) (put-line `count = @{con.count}`))