Changeset 31695 for main/trunk/greenstone3/src/java/org/greenstone/gsdl3/build/GS2PerlConstructor.java
- Timestamp:
- 2017-05-22T16:43:13+12:00 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/src/java/org/greenstone/gsdl3/build/GS2PerlConstructor.java
r31669 r31695 504 504 // We don't include the cancel check here, as superclass CollectionConstructor.stopAction(), which set 505 505 // 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: 508 509 // http://stackoverflow.com/questions/6859681/better-way-to-signal-other-thread-to-stop 509 510 // https://docs.oracle.com/javase/tutorial/essential/concurrency/interrupt.html 510 511 // https://docs.oracle.com/javase/7/docs/api/java/lang/Thread.html#interrupted() 511 512 // 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 finally518 // t hat 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. 519 520 520 521 } catch(IOException e) {
Note:
See TracChangeset
for help on using the changeset viewer.