You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avalon.apache.org by "Noel J. Bergman" <no...@devtech.com> on 2002/12/09 11:24:04 UTC

Discontinuity between createThreadPool and SoftResourcePool

Peter,

Actually, I've contributed before by proxy.  And I did mention this some
months ago, but be that as it may, here is the problem:

org.apache.avalon.cornerstone.blocks.threads.DefaultThreadManager.configureT
hreadPool:

final DefaultThreadPool threadPool = new DefaultThreadPool(name, maxThreads,
threadContext);

--------

org.apache.avalon.excalibur.thread.impl.DefaultThreadPool.DefaultThreadPool(
String name, int capacity, ThreadContext context)

        m_underlyingPool = new SoftResourceLimitingPool( this, capacity );

--------

excalibur.pool.SoftResourceLimitingPool.SoftResourceLimitingPool(ObjectFacto
ry factory, int min)

        this( factory, null, min, min * 2 );

--------

Note how maxThreads passed by configureThreadPool into DefaultThreadPool as
the capacity became the min passed to SoftResourceLimitingPool.

One problem is that DefaultThreadPool doesn't have a semantic for min.  The
int value "capacity" could be interpreted as either a min capacity or a max,
and obviously there was a disconnect at some point.  My own preference is
that if you are going to discard something, discard my min, not my max.

As for how you want to fix it, that's up to you.  One way:

    public DefaultThreadPool( final String name,
                              final int min, final int max,
                              final ThreadContext context )
        throws Exception
    {
        super( name );
        m_underlyingPool = new SoftResourceLimitingPool( this, min, max );
        m_pool = new BasicThreadPool( this, name, m_underlyingPool,
context );
    }

    threadPool = new DefaultThreadPool(name, minThreads, maxThreads,
threadContext);

That's two quick changes.

	--- Noel

-----Original Message-----
From: Peter Donald [mailto:peter@realityforge.org]
Sent: Monday, December 09, 2002 3:09
To: Avalon Developers List
Subject: Re: DO NOT REPLY [Bug 15060] - deadlock in ResourceLimitingPool


On Mon, 9 Dec 2002 12:46, Noel J. Bergman wrote:
> Peter,
>
> While you're working in the pooling code, do you think that you could fix
> the pooling bug that causes the max to become the min, and the real max to
> be twice the original?
>
> Trace the constructor calls.

If you know what the problem is and where the problem is then it is a
perfect
opportunity for you to make your first contribution. Otherwise bugzilla it
so
it doesn't fall through the cracks.

--
Cheers,


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Discontinuity between createThreadPool and SoftResourcePool

Posted by "Noel J. Bergman" <no...@devtech.com>.
It is http://issues.apache.org/bugzilla/show_bug.cgi?id=15296.

I had actually posted a followup to this, but it didn't make it to the list,
so I pasted it into the bugzilla report.

By the way, apparently bugzilla doesn't know that Avalon is past 4.0b3.

	--- Noel

-----Original Message-----
From: Peter Donald [mailto:peter@realityforge.org]
Sent: Wednesday, December 11, 2002 17:51
To: Avalon Developers List
Subject: Re: Discontinuity between createThreadPool and SoftResourcePool


Works for me. Want to send a diff and/or add it into bugzilla.


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Discontinuity between createThreadPool and SoftResourcePool

Posted by Peter Donald <pe...@realityforge.org>.
Works for me. Want to send a diff and/or add it into bugzilla.

On Mon, 9 Dec 2002 21:24, Noel J. Bergman wrote:
> Peter,
>
> Actually, I've contributed before by proxy.  And I did mention this some
> months ago, but be that as it may, here is the problem:
>
> org.apache.avalon.cornerstone.blocks.threads.DefaultThreadManager.configure
>T hreadPool:
>
> final DefaultThreadPool threadPool = new DefaultThreadPool(name,
> maxThreads, threadContext);
>
> --------
>
> org.apache.avalon.excalibur.thread.impl.DefaultThreadPool.DefaultThreadPool
>( String name, int capacity, ThreadContext context)
>
>         m_underlyingPool = new SoftResourceLimitingPool( this, capacity );
>
> --------
>
> excalibur.pool.SoftResourceLimitingPool.SoftResourceLimitingPool(ObjectFact
>o ry factory, int min)
>
>         this( factory, null, min, min * 2 );
>
> --------
>
> Note how maxThreads passed by configureThreadPool into DefaultThreadPool as
> the capacity became the min passed to SoftResourceLimitingPool.
>
> One problem is that DefaultThreadPool doesn't have a semantic for min.  The
> int value "capacity" could be interpreted as either a min capacity or a
> max, and obviously there was a disconnect at some point.  My own preference
> is that if you are going to discard something, discard my min, not my max.
>
> As for how you want to fix it, that's up to you.  One way:
>
>     public DefaultThreadPool( final String name,
>                               final int min, final int max,
>                               final ThreadContext context )
>         throws Exception
>     {
>         super( name );
>         m_underlyingPool = new SoftResourceLimitingPool( this, min, max );
>         m_pool = new BasicThreadPool( this, name, m_underlyingPool,
> context );
>     }
>
>     threadPool = new DefaultThreadPool(name, minThreads, maxThreads,
> threadContext);
>
> That's two quick changes.
>
> 	--- Noel
>
> -----Original Message-----
> From: Peter Donald [mailto:peter@realityforge.org]
> Sent: Monday, December 09, 2002 3:09
> To: Avalon Developers List
> Subject: Re: DO NOT REPLY [Bug 15060] - deadlock in ResourceLimitingPool
>
> On Mon, 9 Dec 2002 12:46, Noel J. Bergman wrote:
> > Peter,
> >
> > While you're working in the pooling code, do you think that you could fix
> > the pooling bug that causes the max to become the min, and the real max
> > to be twice the original?
> >
> > Trace the constructor calls.
>
> If you know what the problem is and where the problem is then it is a
> perfect
> opportunity for you to make your first contribution. Otherwise bugzilla it
> so
> it doesn't fall through the cracks.

-- 
Cheers,

Peter Donald
--------------------------------------------
 Beer is proof that God loves us and wants 
 us to be happy. -- Benjamin Franklin
-------------------------------------------- 


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>