leosutic    2002/09/06 08:40:52

  Modified:    event/src/java/org/apache/excalibur/event/command
                        TPCThreadManager.java
  Log:
  Added lazy init of m_processors so the ThreadManager can run in sandboxed 
environments. Patch from Christopher Kohlhaas [[EMAIL PROTECTED]].
  
  Revision  Changes    Path
  1.25      +11 -4     
jakarta-avalon-excalibur/event/src/java/org/apache/excalibur/event/command/TPCThreadManager.java
  
  Index: TPCThreadManager.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon-excalibur/event/src/java/org/apache/excalibur/event/command/TPCThreadManager.java,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- TPCThreadManager.java     8 Aug 2002 00:36:26 -0000       1.24
  +++ TPCThreadManager.java     6 Sep 2002 15:40:52 -0000       1.25
  @@ -80,7 +80,7 @@
   {
       private DefaultThreadPool m_tpool;
       private long m_blockTimeout = 1000L;
  -    private int m_processors = SystemUtil.numProcessors();
  +    private int m_processors = -1;
       private int m_threadsPerProcessor = 1;
   
       /**
  @@ -114,9 +114,11 @@
        */
       public void parameterize( Parameters parameters ) throws ParameterException
       {
  -        this.m_processors =
  -          Math.max( parameters.getParameterAsInteger( "processors", 
SystemUtil.numProcessors() ),
  -                    1 );
  +        this.m_processors = parameters.getParameterAsInteger( "processors", -1);
  +        if (this.m_processors < 1)
  +        {
  +            this.m_processors = Math.max( 1 , SystemUtil.numProcessors() );
  +        }
   
           this.m_threadsPerProcessor =
               Math.max( parameters.getParameterAsInteger( "threads-per-processor", 1 
), 1 );
  @@ -127,6 +129,11 @@
   
       public void initialize() throws Exception
       {
  +        if (this.m_processors < 1)
  +        {
  +            this.m_processors = Math.max( 1 , SystemUtil.numProcessors() );
  +        }
  +        
           if( isInitialized() )
           {
               throw new IllegalStateException( "ThreadManager is already initailized" 
);
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to