[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

concurrent process on MCL



Hi Lispers,

(hope this is not an FAQ).
How can I send several concurrent processes with MCL?

For example below represent the kind of code I would like to write. Here it
defines a producer and a consumer. The producer is a loop pushing values on
a stack and the consumer pops the stack values (if any). 

In a general way, two specific functions have to be defined to launch and
stop a process (if it doesn't stop by itself). Should the read-eval-loop be
changed? Should I use the event-manager?

Thanx for any pointers



(defparameter *stack* nil)


(defun fetch-value (stack)
  (let (value)
    (do () ((not (get 'fetch-value 'active-process-p))
            )
      (when stack
        (setf value (pop stack))
        (print value)
        )
      )))


(defun push-value (stack)
  (let ((value 0))
    (do () ((not (get 'put-value 'active-process-p)))
      (when stack
        (push value stack)
        (incf value)
        )
      )))

(defun start-process (process &rest args)
  (setf (get process 'active-process-p) t)
  ;; something obviously wrong here
  (eval-enqueue (apply (symbol-function process) args))
  )

(defun stop-process (process)
  (setf (get process 'active-process-p) nil)
  )

#|
(start-process 'push-value *stack*)
(start-process 'fetch-value *stack*)

|#


---
Lafourcade Mathieu
GETA (Groupe d'Etude pour la Traduction Automatique)
IMAG (Institut de Mathematiques Appliquees de Grenoble)
BP 53 38041 GRENOBLE CEDEX 9, FRANCE
Tel : (33) 76 51 43 80          Fax : (33) 76 51 44 05

mathieu.lafourcade@imag.fr