Return-Path: Delivered-To: apmail-hc-httpclient-users-archive@www.apache.org Received: (qmail 41527 invoked from network); 23 Jun 2008 18:14:17 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 23 Jun 2008 18:14:17 -0000 Received: (qmail 978 invoked by uid 500); 23 Jun 2008 18:14:18 -0000 Delivered-To: apmail-hc-httpclient-users-archive@hc.apache.org Received: (qmail 853 invoked by uid 500); 23 Jun 2008 18:14:18 -0000 Mailing-List: contact httpclient-users-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpClient User Discussion" Delivered-To: mailing list httpclient-users@hc.apache.org Received: (qmail 836 invoked by uid 99); 23 Jun 2008 18:14:18 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 23 Jun 2008 11:14:18 -0700 X-ASF-Spam-Status: No, hits=1.2 required=10.0 tests=SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [209.85.162.180] (HELO el-out-1112.google.com) (209.85.162.180) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 23 Jun 2008 18:13:28 +0000 Received: by el-out-1112.google.com with SMTP id j27so201010elf.25 for ; Mon, 23 Jun 2008 11:13:45 -0700 (PDT) Received: by 10.143.29.17 with SMTP id g17mr4234443wfj.239.1214244824856; Mon, 23 Jun 2008 11:13:44 -0700 (PDT) Received: by 10.142.131.13 with HTTP; Mon, 23 Jun 2008 11:13:44 -0700 (PDT) Message-ID: <1f3854d50806231113l78d49f95uf137c61a5e695c56@mail.gmail.com> Date: Mon, 23 Jun 2008 20:13:44 +0200 From: "Quintin Beukes" Sender: quintin@skywalk.co.za To: "HttpClient User Discussion" Subject: Re: isStale() In-Reply-To: <1214244400.6025.22.camel@ubuntu> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <1f3854d50806201607r7b7a96fax37704f8242340799@mail.gmail.com> <1f3854d50806210917i76431ed7w3588108b9a2bacfd@mail.gmail.com> <1214071686.6015.17.camel@ubuntu> <1f3854d50806211138v15fdb9c0l7fe2e38e839f20be@mail.gmail.com> <485E21B4.3050707@apache.org> <1f3854d50806220810g2a3ec480t7d44f2ec7fb9adf1@mail.gmail.com> <1214150027.24597.9.camel@ubuntu> <1f3854d50806220913tde15151re8ba603ab05650fe@mail.gmail.com> <1f3854d50806221404u21cdde7dw4acbea2e71462781@mail.gmail.com> <1214244400.6025.22.camel@ubuntu> X-Google-Sender-Auth: 4da3bb7381778fc0 X-Virus-Checked: Checked by ClamAV on apache.org 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); On 6/23/08, Oleg Kalnichevski 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 > > -- Quintin Beukes --------------------------------------------------------------------- To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org For additional commands, e-mail: httpclient-users-help@hc.apache.org