From: <pj...@us...> - 2009-10-10 06:05:43
|
Revision: 6852 http://jython.svn.sourceforge.net/jython/?rev=6852&view=rev Author: pjenvey Date: 2009-10-10 06:05:26 +0000 (Sat, 10 Oct 2009) Log Message: ----------- add a flag to sys as a faster SystemRestart check for the code objects. otherwise currentThread().isInterrupted() is now a noticable performance hit Modified Paths: -------------- trunk/jython/src/org/python/core/PyBaseCode.java trunk/jython/src/org/python/core/PySystemState.java trunk/jython/src/org/python/core/PyTableCode.java trunk/jython/src/org/python/util/jython.java Modified: trunk/jython/src/org/python/core/PyBaseCode.java =================================================================== --- trunk/jython/src/org/python/core/PyBaseCode.java 2009-10-10 05:44:16 UTC (rev 6851) +++ trunk/jython/src/org/python/core/PyBaseCode.java 2009-10-10 06:05:26 UTC (rev 6852) @@ -98,7 +98,7 @@ // Check for interruption, which is used for restarting the interpreter // on Jython - if (Thread.currentThread().isInterrupted()) { + if (ts.systemState._systemRestart && Thread.currentThread().isInterrupted()) { throw new PyException(_systemrestart.SystemRestart); } return ret; Modified: trunk/jython/src/org/python/core/PySystemState.java =================================================================== --- trunk/jython/src/org/python/core/PySystemState.java 2009-10-10 05:44:16 UTC (rev 6851) +++ trunk/jython/src/org/python/core/PySystemState.java 2009-10-10 06:05:26 UTC (rev 6852) @@ -144,6 +144,9 @@ private int recursionlimit = 1000; + /** true when a SystemRestart is triggered. */ + public boolean _systemRestart = false; + public PySystemState() { initialize(); modules = new PyStringMap(); Modified: trunk/jython/src/org/python/core/PyTableCode.java =================================================================== --- trunk/jython/src/org/python/core/PyTableCode.java 2009-10-10 05:44:16 UTC (rev 6851) +++ trunk/jython/src/org/python/core/PyTableCode.java 2009-10-10 06:05:26 UTC (rev 6852) @@ -198,7 +198,7 @@ // Check for interruption, which is used for restarting the interpreter // on Jython - if (Thread.currentThread().isInterrupted()) { + if (ts.systemState._systemRestart && Thread.currentThread().isInterrupted()) { throw new PyException(_systemrestart.SystemRestart); } return ret; Modified: trunk/jython/src/org/python/util/jython.java =================================================================== --- trunk/jython/src/org/python/util/jython.java 2009-10-10 05:44:16 UTC (rev 6851) +++ trunk/jython/src/org/python/util/jython.java 2009-10-10 06:05:26 UTC (rev 6852) @@ -355,8 +355,9 @@ * Run any finalizations on the current interpreter in preparation for a SytemRestart. */ public static void shutdownInterpreter() { - // Stop all the active threads + // Stop all the active threads and signal the SystemRestart thread.interruptAllThreads(); + Py.getSystemState()._systemRestart = true; // Close all sockets -- not all of their operations are stopped by // Thread.interrupt (in particular pre-nio sockets) try { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |