chicken-users
[Top][All Lists]
Advanced

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

[Chicken-users] Repetitive callback into scheme from C thread hangs


From: Matthew David Parker
Subject: [Chicken-users] Repetitive callback into scheme from C thread hangs
Date: Tue, 22 Nov 2005 17:42:37 -0500 (EST)

Normally to do a callback I'd do this:

(define call.foo
        (foreign-safe-lambda void "callfoo"))

(define AImain
        (lambda ()
                (printf "hello\n")))

(define foo
        (foreign-safe-wrapper void "foo"
                () (lambda () (AImain))))

And then in my C code:

void callfoo (void) {
        foo();
}


I've tested this and it works well.  I can even redefine "AImain" and get
it to do different things when I callback foo.

For this game I'm working on, it runs in a thread and runs at about 16
frames per second.  For every frame I want it to callback to an AI
function in scheme.  However, when I implement the above into my game, the
game hangs when it calls foo() and it doesn't actually do anything in the
foo function.  I'm guessing this has something to do with it running from
a thread?  Also, in the above example I call a C function from scheme that
immediately calls back into scheme, though in my game I just set a
variable that says it can start calling "foo", and when it actually calls
foo is when it hangs.  I am hoping to do this without including
"chicken.h" in my game library (to make it more versatile).  Is that even
possible?




reply via email to

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