On Sun, 6 Aug 2000, Jiang Wu wrote:

> How are you running your example?  Are you starting the JVM first, then load
> TclBlend?  If not, you are not using "serviceEvent()" when executing
> "vwait".
> 
> The easy way to reproduce the problems related to the Notifier is to build a
> Java based shell, e.g. using the Jacl shell, that uses TclBlend.  Start this
> shell, then:
> 
>     cd <tcl_source_dir>/tests
>     source all.tcl
> 
> Some of the Tcl tests will pass, other will fail.  But the test suite should
> finish.  The bugs in the Notifier will cause deadlock or busy wait.
> 
> -- Jiang Wu
>    [EMAIL PROTECTED]


I need to be able to reproduce this error in regular Tcl Blend.
Your note got me looking at my example again, I was using Tcl + Tcl Blend
without using the Notifier to queue the vwait event. I fixed my
test so that it now detects the deadlock case:


import tcl.lang.*;

public class AppendEventQueueThread extends Thread {
    private Interp interpInOtherThread;
    public int numQueued = 0;
    public int numProcessed = 0;
    public boolean killed = false;
    private final boolean debug = true;

    public AppendEventQueueThread(Interp i) {
        interpInOtherThread = i;
    }
    
    public void run() {
        if (debug) {
            System.out.println("running AppendEventQueueThread");
        }

        while (! killed) {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {}


            TclEvent event = new TclEvent() {
                public int processEvent (int flags) {
                    numProcessed++;
                    return 1;
                }
            };

            // Add the event to the thread safe event queue
            interpInOtherThread.getNotifier().queueEvent(event, TCL.QUEUE_TAIL);
            numQueued++;
        }

        if (debug) {
            System.out.println("done running AppendEventQueueThread");
        }
    }

    public static void queueVwaitEvent(final Interp interp) {
            TclEvent event = new TclEvent() {
                public int processEvent (int flags) {
                    try {
                    interp.eval("after 10000 {set wait 1}", 0);
                    interp.eval("vwait wait", 0);
                    } catch (TclException ex) {}
                    return 1;
                }
            };

            // Add the event to the thread safe event queue
            interp.getNotifier().queueEvent(event, TCL.QUEUE_TAIL);
    }
}



package require java

set AQT [java::new AppendEventQueueThread [java::getinterp]]

$AQT start

set orig_numQueued [java::field $AQT numQueued]

java::call AppendEventQueueThread queueVwaitEvent [java::getinterp]

set numQueued [java::field $AQT numQueued]
set numProcessed [java::field $AQT numProcessed]

# Kill this other thread.
java::field $AQT killed 1



% set orig_numQueued                
0
% set numQueued
0
% set numProcessed
0


So, that is good as I can now reproduce the problem.
The new problem is that this bad behavior does not
seem to go away after your Notifier patch.
If I do 2 vwaits, then a single event is
processed from the event loop, but that seems to be all.

Any ideas what might be up with this?

Mo DeJong
Red Hat Inc

----------------------------------------------------------------
The TclJava mailing list is sponsored by Scriptics Corporation.
To subscribe:    send mail to [EMAIL PROTECTED]  
                 with the word SUBSCRIBE as the subject.
To unsubscribe:  send mail to [EMAIL PROTECTED] 
                 with the word UNSUBSCRIBE as the subject.
To send to the list, send email to '[EMAIL PROTECTED]'. 
An archive is available at http://www.mail-archive.com/tcljava@scriptics.com

Reply via email to