hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: isStale()
Date Mon, 23 Jun 2008 18:39:48 GMT
On Mon, 2008-06-23 at 20:13 +0200, Quintin Beukes wrote:
> Hey,
> 
> One can either modify the the method to either
> (1) Implement a priority queue, which will give a perfect distribution.
> (2) Modify the method to do this:
> int i;
> synchronized (this)
> {
>   int i = this.currentWorker++ % this.workerCount;
>   if (i == 0) this.currentWorker = 1;
> }
> this.dispatchers[i].addChannel(entry);
> 

I would not like to over-synchronize just to have a pretty worker count.
and would just leave this bit of code as is. The worker count as well as
the new channel distribution do not really need to be very precise. 

Can you live with that?

Oleg


> On 6/23/08, Oleg Kalnichevski <olegk@apache.org> wrote:
> > On Sun, 2008-06-22 at 23:04 +0200, Quintin Beukes wrote:
> >  > Hey,
> >  >
> >  > I was busy stepping the NIO code, and noticed the following:
> >  > this.dispatchers[this.currentWorker++ % this.workerCount].addChannel(entry);
> >  >
> >  > Is this safe? Since currentWorker will eventually wrap around to a
> >  > negative number. It will take a while, a long long while, but I don't
> >  > notice any resets anywhere, so I assume after running for a few
> >  > months, or under extremely high volume it will eventually fail.
> >  >
> >
> >
> > I do not think it is unsafe given the fact we are only interested in
> >  more or less equal distribution of new connections among existing
> >  workers, but I agree it would be nice to have the count wrap around to
> >  1.
> >
> >  We happily take patches ;-)
> >
> >
> >  > PS: Of all the open source projects' source code I've worked with,
> >  > HttpComponents have been the biggest pleasure of all. The code is
> >  > very... "intelligable". Sometimes code is over "complexified", or made
> >  > so abstract that one cannot see how things link up with each other, or
> >  > just badly written. Thanks for it all!
> >  >
> >
> >
> > I am glad you found source code comprehensible. I hope it is useful too.
> >
> >  Cheers
> >
> >
> >  Oleg
> >
> >
> >  ---------------------------------------------------------------------
> >  To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> >  For additional commands, e-mail: httpclient-users-help@hc.apache.org
> >
> >
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org


Mime
View raw message