; Copyright 2005 Kevin Reid, under the terms of the MIT X license ; found at http://www.opensource.org/licenses/mit-license.html ................ (defpackage :e.lisp-test.turn (:use :cl :e.lisp-test :elib :e.util)) (cl:in-package :e.lisp-test.turn) (deftest vat-label.init (vat-label (make-instance 'vat :label "aardvarks")) "aardvarks") (deftest vat-label.establish-vat (prog2 (establish-vat :label "initiative") (vat-label *vat*) (setf *vat* nil)) "initiative") (deftest vat-label.with-vat (block nil (with-vat (:label "potato") (return (vat-label *vat*)))) "potato") (defun stream-handler-target (stream) ;; XXX this belongs in e.util #+sbcl (sb-sys:fd-stream-fd stream) #-sbcl (error "not implemented")) #-(and) ;; XXX *TEMPORARILY* disabled because it leaks fds (deftest exclusive-io-handler-pound (let* ((vat (make-instance 'vat :label "exclusive-io-handler-pound test")) (*vat* vat) (group (make-instance 'io-handler-exclusion-group)) (seen 0) (streams (loop for i below 20 collect (external-process-output-stream (run-program "/bin/sh" (list "-c" (format nil "sleep 1; echo ~S" i)) :output :stream :wait nil)))) (handlers (mapcar (lambda (s &aux handler) (setf handler (add-exclusive-io-handler group (stream-handler-target s) :input (lambda (target) (with-turn (vat) (read s) ;(warn "got ~S" ...) (incf seen) (remove-exclusive-io-handler handler)))))) streams))) (unwind-protect (block pound (labels ((task1 (i) ;(warn "task1 ~A" i) (when (>= seen (length streams)) (return-from pound)) (e<- (e.knot::wrap-function #'task1) |run| (1+ i)))) (task1 0) (vat-loop))) (map nil #'remove-exclusive-io-handler handlers)) (values)))