Return-Path: Delivered-To: apmail-jakarta-tomcat-dev-archive@apache.org Received: (qmail 87223 invoked from network); 30 Dec 2001 09:17:55 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 30 Dec 2001 09:17:55 -0000 Received: (qmail 11752 invoked by uid 97); 30 Dec 2001 09:18:01 -0000 Delivered-To: qmlist-jakarta-archive-tomcat-dev@jakarta.apache.org Received: (qmail 11736 invoked by uid 97); 30 Dec 2001 09:18:01 -0000 Mailing-List: contact tomcat-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Tomcat Developers List" Reply-To: "Tomcat Developers List" Delivered-To: mailing list tomcat-dev@jakarta.apache.org Received: (qmail 11725 invoked from network); 30 Dec 2001 09:18:00 -0000 Message-ID: <3C2EE81A.E3BB6D76@distributopia.com> Date: Sun, 30 Dec 2001 04:10:34 -0600 From: "Christopher K. St. John" X-Mailer: Mozilla 4.61 [en] (X11; I; Linux 2.0.36 i686) X-Accept-Language: en MIME-Version: 1.0 To: tomcat-dev@jakarta.apache.org Subject: StandardPipeline and ThreadLocal Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N The first thing that pops into my head when I see the Pipeline pattern (and read Craig's [PROPOSAL] Tomcat 4.0-beta API Change: Valve APIs post), is something along the lines of the psuedocode at the end of the message. The semantics are subtly different from the current StandardPipeline, but I think only in bizarre cases like if a Valve spawned a thread and then both threads tried to call invokeNext on the same ValveContext. It's not like the existing code is exactly broken, but the use of ThreadLocal is certainly a little unexpected. It violates the "avoid suprising code" rule. (Well, it suprised me, anyway) Do the semantics differ in some other way that makes the implementation below incorrect? (Ignore bugs, you get the idea) If not, would whoever's responsible for that code be willing to accept a patch to get rid of the ThreadLocal? class ValveContext { Pipeline p; int i; public void invokeNext(req, rsp) { if (i==p.valves.length) if (p.basic) v = p.basic; else v = p.valves[i++]; if (!v) throw exception; v.invoke(req, rsp, this); } } class StandardPipeline { Vector valves = new Vector(); Valve basic; public void invoke(req, rsp) { ctx = new ValveContext(0, this); ctx.invokeNext(req, rsp); } } -- Christopher St. John cks@distributopia.com DistribuTopia http://www.distributopia.com -- To unsubscribe, e-mail: For additional commands, e-mail: