RE: Re: BlockingQueue and capacity issue

"Jean Morissette" <[email protected]> Wed, 01 Dec 2004 02:18:02 -0500
Newsgroups gmane.comp.java.seda.user
Message-ID <[email protected]>
<html><div style='background-color:'><DIV class=RTE>
<P>I want to support RateLimitingPredicate, thus case B don't seem an option.&nbsp; I think that its a good idea to use a timeout to wake up a thread, when we use a RateLimitingPredicate.&nbsp; This timeout can be computed easily like this:</P>
<P>timeout = 1000 / RateLimitingPredicate.getTargetRate</P>
<P>But this computed timeout consider that only one thread try to enqueue.&nbsp; So, we can adjust this computed timeout dynamically for each thread, by example:</P>
<P>delay = System.currentTimeMillis() - lasttime</P>
<P>timeout += delay</P>
<P>I have done some preliminary tests and the results are very good!&nbsp; But I don't want to put this code in queue implementations; queue implementaions should not be dependent on concrete EnqueuePredicateIF.&nbsp;&nbsp;Maybe we&nbsp;should add a method EnqueuePredicateIF.blocking_accept...</P>
<P>PS: I will reformat the code with tabs.</P></DIV>
<DIV></DIV>&gt;From: Quartz &lt;[email protected]&gt;
<DIV></DIV>&gt;To: Jean Morissette &lt;[email protected]&gt;
<DIV></DIV>&gt;Subject: RE: [SEDA-users] Re: BlockingQueue and capacity issue
<DIV></DIV>&gt;Date: Tue, 30 Nov 2004 19:49:10 -0800 (PST)
<DIV></DIV>&gt;
<DIV></DIV>&gt; &gt;The question is what we should do to wake up waiting thread in the case of RateLimitingPredicate?
<DIV></DIV>&gt;&nbsp;&nbsp;&gt;Should we use a timeout or a notification?
<DIV></DIV>&gt; &gt;
<DIV></DIV>&gt; &gt;The problem is that I cannot see what notification condition I could use or what should be the
<DIV></DIV>&gt; &gt;timeout value.
<DIV></DIV>&gt;
<DIV></DIV>&gt;Let me guess. You wonder how the predicate can spontaneously kick a waiting writer out of blocked
<DIV></DIV>&gt;state.
<DIV></DIV>&gt;
<DIV></DIV>&gt;Well, I didn't design this predicate, and it is sometimes a bad idea to inline the rate caculation
<DIV></DIV>&gt;with the .accept() method call. It could have been orthogonal (control thread?). In such design,
<DIV></DIV>&gt;you would have found the answer right away. Matt did that a bit too often, but the guy had good
<DIV></DIV>&gt;reasons: avoid wasting threads.
<DIV></DIV>&gt;
<DIV></DIV>&gt;I assumed only a queue reader could notify a writer: that it's time to enqueue (case B) or to
<DIV></DIV>&gt;retry .accept() (case A). If the predicate instance must kick a writer out of wait, spontaneously,
<DIV></DIV>&gt;without the waiter (writer) thread being aware of any timeout (the timeout you seam to be worrying
<DIV></DIV>&gt;about), then I see only the reader thread which would have to poke the predicate somehow with a 10
<DIV></DIV>&gt;foot stick...('cause readers are really not in the business of enqueue predicates...) Again, this
<DIV></DIV>&gt;is only for case A, because in case B, only queue size is considered, not the predicate policy.
<DIV></DIV>&gt;
<DIV></DIV>&gt;PS: PLEASE, I beg you, use tabs, not spaces for indentation in seda3.
<DIV></DIV>&gt;Tabs are the perfect abstract representation of indentation. You want it 2 spaces, you still can
<DIV></DIV>&gt;with tabs, just set your IDE editors to render 2 space for tabs.
<DIV></DIV>&gt;But keep using tabs indents -all the time-.
<DIV></DIV>&gt;
<DIV></DIV>&gt;We are programmers, not ascii graphics designers...
<DIV></DIV>&gt;;-)
<DIV></DIV>&gt;
<DIV></DIV>
<DIV></DIV>
<DIV></DIV></div></html>



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. 
http://productguide.itmanagersjournal.com/