This is the mail archive of the guile@cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: c++ -> guile threading


Peter Amstutz <tetron@student.umass.edu> writes:

> On Tue, 11 May 1999, Greg Harvey wrote:
> 
> > > > (I have no idea about threads stuff ;)
> > 
> > I'd like to stress that once again :). I was thinking that the current
> > module would (and probably should) be local to the thread, but this is
> > not the case. Trying to figure out how to do it does make for a nice
> > little mind bending problem ;), but I think the only way you could do
> > this would be to make the various module variables into fluids, or
> > something similar.

Doh, that's probably not even necessary (there's something to be said for
documentation *sigh*). In any case, you can use save-module-excursion,
like this:

guile> (make-thread (lambda () 
        (save-module-excursion 
                (lambda () 
                        (define-module (restricted)) 
                                (display (current-module))))))

#<thread 805d528>
guile> #<directory restricted 401b4d08>
guile> (current-module)
#<directory guile-user 401c6fc8>

Unfortunately, it's not quite there for what this needs:

guile> (make-thread (lambda () (save-module-excursion 
        (lambda () (define-module (restricted)) (let loop ((n 1)) (loop (+ n 1)))))))
#<thread 805d528>
guile> (current-module)
#<directory restricted 401b4b00>

There probably is a way to make this work, tho.

-- 
Greg

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]