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. I think that its a good idea to use a timeout to wake up a thread, when we use a RateLimitingPredicate. 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. 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! But I don't want to put this code in queue implementations; queue implementaions should not be dependent on concrete EnqueuePredicateIF. Maybe we should add a method EnqueuePredicateIF.blocking_accept...</P> <P>PS: I will reformat the code with tabs.</P></DIV> <DIV></DIV>>From: Quartz <[email protected]> <DIV></DIV>>To: Jean Morissette <[email protected]> <DIV></DIV>>Subject: RE: [SEDA-users] Re: BlockingQueue and capacity issue <DIV></DIV>>Date: Tue, 30 Nov 2004 19:49:10 -0800 (PST) <DIV></DIV>> <DIV></DIV>> >The question is what we should do to wake up waiting thread in the case of RateLimitingPredicate? <DIV></DIV>> >Should we use a timeout or a notification? <DIV></DIV>> > <DIV></DIV>> >The problem is that I cannot see what notification condition I could use or what should be the <DIV></DIV>> >timeout value. <DIV></DIV>> <DIV></DIV>>Let me guess. You wonder how the predicate can spontaneously kick a waiting writer out of blocked <DIV></DIV>>state. <DIV></DIV>> <DIV></DIV>>Well, I didn't design this predicate, and it is sometimes a bad idea to inline the rate caculation <DIV></DIV>>with the .accept() method call. It could have been orthogonal (control thread?). In such design, <DIV></DIV>>you would have found the answer right away. Matt did that a bit too often, but the guy had good <DIV></DIV>>reasons: avoid wasting threads. <DIV></DIV>> <DIV></DIV>>I assumed only a queue reader could notify a writer: that it's time to enqueue (case B) or to <DIV></DIV>>retry .accept() (case A). If the predicate instance must kick a writer out of wait, spontaneously, <DIV></DIV>>without the waiter (writer) thread being aware of any timeout (the timeout you seam to be worrying <DIV></DIV>>about), then I see only the reader thread which would have to poke the predicate somehow with a 10 <DIV></DIV>>foot stick...('cause readers are really not in the business of enqueue predicates...) Again, this <DIV></DIV>>is only for case A, because in case B, only queue size is considered, not the predicate policy. <DIV></DIV>> <DIV></DIV>>PS: PLEASE, I beg you, use tabs, not spaces for indentation in seda3. <DIV></DIV>>Tabs are the perfect abstract representation of indentation. You want it 2 spaces, you still can <DIV></DIV>>with tabs, just set your IDE editors to render 2 space for tabs. <DIV></DIV>>But keep using tabs indents -all the time-. <DIV></DIV>> <DIV></DIV>>We are programmers, not ascii graphics designers... <DIV></DIV>>;-) <DIV></DIV>> <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/