On Sat, Feb 17, 2001 at 12:00:30AM -0500, Gianni Johansson wrote:
> On Monday 12 February 2001 17:12, you wrote:
>
> > > > Why not just use a counter that's incremented when jobs are dequeued and
> > > run in ThreadPool.run() and decremented in ThreadPool.reclaim() ?
> >
> > I take it back. Since reclaim is in the finally block of EThread, this
> > will work. I've worked in the necessary changes.
> >
> > Bad, could you backport them out of experimental.
> >
> > GJ: Try it this time. It doesnt seem to report negative values.
>
> I retested. There's still at least one bad bug.
>
> It causes the ThreadPool.run() to intermently stop running jobs even though
> less than maxThreads threads are running.
I'm starting to think that recoding the damned pool is a better overall
solution. >:|
>
> See comments in source:
>
> /**
> * Activates this ThreadPool. This ThreadPool will grab a queued job,
> * associate it with an EThread, and tell the EThread to begin. It does
> * this over and over again, until it is {@link halt halt}ed.
> */
>
> public void run() {
> while (run) {
> try {
>
> // Block until both an EThread is available and a job is
> // queued.
>
>
> EThread host=null;
> if (maxThreads > 0 || !threads.isEmpty())
> // ^--- LOOK HERE
> // This condition can evautate to true even when
> // threads.size() == 0 and
> // runningThreads() < maxThreads.
> // In this case pop blocks an EThread is push()'d
> // into threads. That could take a long time....
Its even possible that it wouldn't ever happen. This should be
if (!threads.isEmpty() && runningThreads() < maxThreads() ||
maxThreads==0)
> }
>
> Also, the current implementation of reclaim will release all of
> the preallocated Ethreads until only maxPoolThreads remain when the
> ThreadPool quiesces, so why not just preallocate maxPoolThreads in
> the first place, instead of maxThreads?
Absolutely. That behaviour (reclaim releasing until we're down to
maxPoolThreads) was added, and I obviously forgot to reconcile it with the
initially filling.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 232 bytes
Desc: not available
URL:
<https://emu.freenetproject.org/pipermail/devl/attachments/20010218/2e2aa299/attachment.pgp>