Ignore:
Timestamp:
2017-05-22T16:43:13+12:00 (7 years ago)
Author:
ak19
Message:

Bringing GS3 src code's SafeProcess up to speed with GLI version, with some addiitonal minor changes to be included in the GLI version hereafter. Tested on Linux.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/src/java/org/greenstone/gsdl3/build/GS2PerlConstructor.java

    r31669 r31695  
    504504    // We don't include the cancel check here, as superclass CollectionConstructor.stopAction(), which set
    505505    // this.cancel to true, never got called anywhere.
    506     // But I think a proper cancel of our perl process launched by this GS2PerlConstructor Thread object
    507     // and of the worker threads it launches, could be implemented with interrupts. See:
     506    // But a proper cancel of our perl process launched by this GS2PerlConstructor Thread object
     507    // and of the worker threads it launches is now implemented in SafeProcess.cancelRunningProcess()
     508    // with interrupts. See:
    508509    // http://stackoverflow.com/questions/6859681/better-way-to-signal-other-thread-to-stop
    509510    // https://docs.oracle.com/javase/tutorial/essential/concurrency/interrupt.html
    510511    // https://docs.oracle.com/javase/7/docs/api/java/lang/Thread.html#interrupted()
    511512    // https://praveer09.github.io/technology/2015/12/06/understanding-thread-interruption-in-java/
    512     // The code that calls GS2PerlConstructor.stopAction() should also call GSPerlConstructor.interrupt()
    513     // Then in SafeProcess.runProcess(), I think the waitFor() will throw an InterruptedException()
    514     // This can be caught and interrupt() called on SafeProcess' workerthreads,
    515     // Any workerthreads' run() methods that block (IO, loops) can test this.isInterrupted()
    516     // and can break out of any loops and release resources in finally.
    517     // Back in SafeProcess.runProcess, the InterruptedException catch block will be followed by finally
    518     // that will clear up any further resources and destroy the process forcibly if it hadn't been ended.
     513    // If cancel is to be implemented for GS2PerlConstructor, then the code that calls
     514    // GS2PerlConstructor.stopAction() should also call or result in a call to the SafeProcess instance's
     515    // cancelRunningProcess() method.
     516    // For a simple example of the use of SafeProcess' cancel feature, see GLI's GShell. For a more
     517    // complicated example, see GLI's DownloadJob.java, which implements SafeProcess.MainHandler to do
     518    // additional work when a process is cancelled while still running (and therefore has to be prematurely
     519    // terminated) a.o.t. a process that's cancelled when it's already terminated naturally.
    519520
    520521    } catch(IOException e) {
Note: See TracChangeset for help on using the changeset viewer.