[Armedbear-devel] process run function

Rolando Pereira rolando_pereira at sapo.pt
Thu May 29 19:32:48 UTC 2014


bonasso <bonasso at traclabs.com> writes:

> In ACL one starts a process with a function as follows:
>
> (mp::process-run-function 
>   'start-raps
>   rap::rap-state* 2 nil)
>
> where you give process-run-function the function name and the rest are
> the args to that function.
>
> I couldn't really find how to do that in abcl. system::run-program was
> the closest thing but the definition in the manual didn't seem to be
> what I was looking for.
>

Looking at the documentation of "process-run-function" it seems that
what you want is to run a function in a another thread and not a system
program (which is what "run-program" is for). You should look in the
manual for the THREADS package, especially the "make-thread" function.

The interface of "make-thread" is slightly different from the interface
of "process-run-function" due to the fact that "make-thread" receives a
function, but not it's arguments.

However you can work around this by providing your own wrapper function
similar to this:

    (defun my-make-thread (name function &rest arguments)
      (threads:make-thread (lambda ()
                             (apply function arguments))
        :name (if (symbolp name)
                  (symbol-name name)
                name)))

And then you can use it like this:

    (setf my-thread (my-make-thread 'my-thread-name #'format nil "This is an example: ~s" 10))
    
    (let (output)
      (setf output (threads:thread-join my-thread))
      output)

And output should contain the string "This is an example: 10".

_______________________________________________
Armedbear-devel mailing list
Armedbear-devel at common-lisp.net
http://common-lisp.net/cgi-bin/mailman/listinfo/armedbear-devel



More information about the armedbear-devel mailing list