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

Re: [sc-dev] Interpreter Locks



On 11/7/06, Ryan Brown <ryan@xxxxxxxxx> wrote:
> You can't. If this were allowed it would be possible to have a call
> stack like this:
> runInterpreter->C primitive->runInterpreter. If the nested call were
> to yield from a coroutine there would be a problem because it might
> have to yield up through the primitive.

You mean if the initial runInterpreter was made within a Routine and
then the second runInterpreter tried to yield? I think it would be
more reasonable to ban doing this

There is no way you can prevent someone from writing code that uses a
coroutine inside of a UI callback. I'm not going to create a big hole
in the runtime.


>
> What you have to do is package up a deferred call like the following
> to your own object, and your object can call runInterpreter:
>
>               SEL sel = @selector(closeWindow);
>               NSMethodSignature *sig = [MyDocument
> instanceMethodSignatureForSelector: sel];
>
>               NSInvocation *anInvocation = [NSInvocation
> invocationWithMethodSignature: sig];
>               SCVirtualMachine* scvm = [SCVirtualMachine sharedInstance];
>               [anInvocation setTarget: doc];
>               [anInvocation setSelector: sel];
>               [scvm defer: anInvocation];

This won't work because the original call from the interpreter is
waiting for a return value.

Sorry, you are out of luck then.

--
--- james mccartney