ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ste...@apache.org
Subject cvs commit: ant/docs/manual running.html
Date Fri, 03 Oct 2003 01:40:48 GMT
stevel      2003/10/02 18:40:48

  Modified:    src/main/org/apache/tools/ant Main.java
               docs/manual running.html
  Log:
  This is the first visible divergence ofAnt1.7 from 1.6...ant 1.7 has a -nice option that
lets you lessen or increase the priority of the main thread. Useful for background builds,
though since it doesnt propagate into forked code, not as useful as it could be.
  
  Revision  Changes    Path
  1.98      +38 -0     ant/src/main/org/apache/tools/ant/Main.java
  
  Index: Main.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/Main.java,v
  retrieving revision 1.97
  retrieving revision 1.98
  diff -u -r1.97 -r1.98
  --- Main.java	2 Oct 2003 06:44:27 -0000	1.97
  +++ Main.java	3 Oct 2003 01:40:48 -0000	1.98
  @@ -153,6 +153,11 @@
       private static boolean isLogFileUsed = false;
   
       /**
  +     * optional thread priority
  +     */
  +    private Integer threadPriority=null;
  +
  +    /**
        * Prints the message of the Throwable if it (the message) is not
        * <code>null</code>.
        *
  @@ -434,6 +439,23 @@
                   }
               } else if (arg.equals("-k") || arg.equals("-keep-going")) {
                   keepGoingMode = true;
  +            } else if (arg.equals("-nice")) {
  +                try {
  +                    threadPriority=Integer.decode(args[i + 1]);
  +                } catch (ArrayIndexOutOfBoundsException aioobe) {
  +                    throw new BuildException(
  +                            "You must supply a niceness value (1-10)"+
  +                            " after the -nice option");
  +                } catch (NumberFormatException e) {
  +                    throw new BuildException("Unrecognized niceness value: " +
  +                            args[i + 1]);
  +                }
  +                i++;
  +                if(threadPriority.intValue()<Thread.MIN_PRIORITY ||
  +                        threadPriority.intValue()>Thread.MAX_PRIORITY) {
  +                    throw new BuildException(
  +                            "Niceness value is out of the range 1-10");
  +                }
               } else if (arg.startsWith("-")) {
                   // we don't have any more args to recognize!
                   String msg = "Unknown argument: " + arg;
  @@ -632,9 +654,23 @@
                   System.setOut(new PrintStream(new DemuxOutputStream(project, false)));
                   System.setErr(new PrintStream(new DemuxOutputStream(project, true)));
   
  +
                   if (!projectHelp) {
                       project.fireBuildStarted();
                   }
  +
  +                // set the thread priorities
  +                if (threadPriority != null) {
  +                    try {
  +                        project.log("Setting Ant's thread priority to "
  +                                + threadPriority,Project.MSG_VERBOSE);
  +                        Thread.currentThread().setPriority(threadPriority.intValue());
  +                    } catch (SecurityException swallowed) {
  +                        //we cannot set the priority here.
  +                        project.log("A security manager refused to set the -nice value");
  +                    }
  +                }
  +
                   project.init();
                   project.setUserProperty("ant.version", getAntVersion());
   
  @@ -826,6 +862,8 @@
           msg.append("  -inputhandler <class>  the class which will handle input requests"
+ lSep);
           msg.append("  -find <file>           (s)earch for buildfile towards the root
of" + lSep);
           msg.append("    -s  <file>           the filesystem and use it" + lSep);
  +        msg.append("  -nice  number          A niceness value for the main thread:" + lSep
+
  +                   "                         1 (lowest) to 10 (highest); 5 is the default"
+ lSep);
           System.out.println(msg.toString());
       }
   
  
  
  
  1.23      +10 -7     ant/docs/manual/running.html
  
  Index: running.html
  ===================================================================
  RCS file: /home/cvs/ant/docs/manual/running.html,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- running.html	2 Oct 2003 06:44:27 -0000	1.22
  +++ running.html	3 Oct 2003 01:40:48 -0000	1.23
  @@ -78,20 +78,21 @@
   <h3><a name="options">Command-line Options Summary</a></h3>
   <pre>ant [options] [target [target2 [target3] ...]]
   Options:
  -  -help                  print this message
  -  -projecthelp           print project help information
  +  -help, -h              print this message
  +  -projecthelp, -p       print project help information
     -version               print the version information and exit
     -diagnostics           print information that might be helpful to
                            diagnose or report problems.
     -quiet, -q             be extra quiet
     -verbose, -v           be extra verbose
  -  -debug                 print debugging information
  -  -emacs                 produce logging information without adornments
  -  -lib <path>            specifies a path to search for jars and classes
  +  -debug, -d             print debugging information
  +  -emacs, -e             produce logging information without adornments
  +  -lib &lt;path&gt;            specifies a path to search for jars and classes
     -logfile &lt;file&gt;        use given file for log
       -l     &lt;file&gt;                ''
     -logger &lt;classname&gt;    the class which is to perform logging
     -listener &lt;classname&gt;  add an instance of class as a project listener
  +  -noinput               do not allow interactive input
     -buildfile &lt;file&gt;      use given buildfile
       -file    &lt;file&gt;              ''
       -f       &lt;file&gt;              ''
  @@ -101,8 +102,10 @@
     -propertyfile &lt;name&gt;   load all properties from file with -D
                            properties taking precedence
     -inputhandler &lt;class&gt;  the class which will handle input requests
  -  -find &lt;file&gt;           search for buildfile towards the root of the
  -                         filesystem and use it
  +  -find &lt;file&gt;           (s)earch for buildfile towards the root of
  +    -s  &lt;file&gt;           the filesystem and use it
  +  -nice  number          A niceness value for the main thread:
  +                         1 (lowest) to 10 (highest); 5 is the default                 
       
   </pre>
   <p>For more information about <code>-logger</code> and
   <code>-listener</code> see
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message