[Top][All Lists]

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

Re: Integrating guile into an existing multi-threaded application

From: Marius Vollmer
Subject: Re: Integrating guile into an existing multi-threaded application
Date: 06 Jun 2002 01:24:09 +0200
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2

Charlie Root <address@hidden> writes:

>  . The guile interpreter may not be fired up by the process's
>    main thread, but some other one, and at some other time than 
>    the end of main(). Is this a problem?

Probably not.  You should be using scm_boot_guile instead of
scm_init_guile, tho, since the latter might not be able to find the
correct stack base in non-main thread.  scm_boot_guile uses the
address of a local variable as the stack base.  A consequence is that
the callback given to scm_boot_guile should never return since
scm_boot_guile will terminate the process then.

(See below why I don't talk about gh_enter here.)

>  . I don't understand the arguments to gh_enter(). The main 
>    thread's argc and argv will not be available to 
>    gh_enter(). If the `inner_main' of gh_enter() is not going
>    to need data passed to it, can these contain dummy values?

Use scm_boot_guile instead of gh_enter since the gh_ interface will
eventually go away.  We will make the scm_ API easy enough to use
instead.  It is reasonably easy already, I hope.

scm_boot_guile has the same argc and argv arguments as gh_enter.
>From the manual:

     `scm_boot_guile' arranges for the Scheme `command-line' function
     to return the strings given by ARGC and ARGV.  If MAIN_FUNC
     modifies ARGC or ARGV, it should call `scm_set_program_arguments'
     with the final list, so Scheme code will know which arguments have
     been processed.

So, you can pass any valid value.  scm_boot_guile (0, NULL, ...)
should be fine.  This will make 'command-line' return the empty list.

>  . Will I be able to use guile's threads inside a system such as
>    the one described (that is, inside a non-main thread) ?

Yes, I think so although I myself have never done it.

>  . Are there other obvious-to-the-seasoned-guiler sorts of issues
>    that I'd do better with if I knew of in advance?

Be careful to always protect your global SCM values and to unprotect
them when they die.  And, try to use scm_ instead of gh_ functions.
If you find you can't do that, yell.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]