On Thu, Feb 5, 2009 at 4:06 AM, Florent Daignière
<[email protected]> wrote:
> * Daniel Cheng <[email protected]> [2009-02-04 23:35:04]:
>
>> On Wed, Feb 4, 2009 at 7:41 PM, Florent Daigniere
>> <[email protected]> wrote:
>> > Daniel Cheng wrote:
>> >> On Wed, Feb 4, 2009 at 12:45 AM,  <[email protected]> wrote:
>> >>> Author: nextgens
>> >>> Date: 2009-02-03 16:45:44 +0000 (Tue, 03 Feb 2009)
>> >>> New Revision: 25492
>> >>>
>> >>> Modified:
>> >>>   trunk/freenet/src/freenet/client/async/ClientRequestScheduler.java
>> >>> Log:
>> >>> Use the executor and not the ticker there
>> >>>
>> >>> Modified: 
>> >>> trunk/freenet/src/freenet/client/async/ClientRequestScheduler.java
>> >>> ===================================================================
>> >>> --- trunk/freenet/src/freenet/client/async/ClientRequestScheduler.java  
>> >>> 2009-02-03 16:24:45 UTC (rev 25491)
>> >>> +++ trunk/freenet/src/freenet/client/async/ClientRequestScheduler.java  
>> >>> 2009-02-03 16:45:44 UTC (rev 25492)
>> >>> @@ -662,18 +662,18 @@
>> >>>                Runnable r = new Runnable() {
>> >>>                        public void run() {
>> >>>                                if(logMINOR) Logger.minor(this, "Running 
>> >>> "+gets.length+" callbacks off-thread for "+block.getKey());
>> >>> -                               for(int i=0;i<gets.length;i++) {
>> >>> +                               for(SendableGet get : gets) {
>> >>>                                        try {
>> >>> -                                               if(logMINOR) 
>> >>> Logger.minor(this, "Calling callback for "+gets[i]+" for "+key);
>> >>> -                                               gets[i].onGotKey(key, 
>> >>> block, ClientRequestScheduler.this);
>> >>> +                                               if(logMINOR) 
>> >>> Logger.minor(this, "Calling callback for "+get+" for "+key);
>> >>> +                                               get.onGotKey(key, block, 
>> >>> ClientRequestScheduler.this);
>> >>>                                        } catch (Throwable t) {
>> >>> -                                               Logger.error(this, 
>> >>> "Caught "+t+" running callback "+gets[i]+" for "+key, t);
>> >>> +                                               Logger.error(this, 
>> >>> "Caught "+t+" running callback "+get+" for "+key, t);
>> >>>                                        }
>> >>>                                }
>> >>>                                if(logMINOR) Logger.minor(this, "Finished 
>> >>> running callbacks");
>> >>>                        }
>> >>>                };
>> >>> -               node.getTicker().queueTimedJob(r, 0); // FIXME ideally 
>> >>> these would be completed on a single thread; when we have 1.5, use a 
>> >>> dedicated non-parallel Executor
>> >>> +               node.executor.execute(r, "Callbacks for "+name);
>> >>
>> >> The FIXME still applies:   node.executor spawn a new thread for every
>> >> request. the original comment call for a "non-parallel" executor.
>> >
>> > There is a patch in the pipes to make it happen; There is no reason why
>> > not to use Executor anymore... All we need is a NativeThread factory.
>>
>> I tried to do this some time before but didn't commit it.
>>
>> That's because the NativeThread priority must be specified on create.
>> That means we need one java.util.concurrent.Executor for each priority.
>> I can't find a (clean) way to keep the number of thread in thread limit.
>
> We can keep the Ticker interface, don't expose the Executors... and add
> a counter.
>
> Btw, what's the reason why the callbacks have to be executed serially?

Thread and lock contention?  > 1000 running sounds insane for me...
maybe just me.

>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (GNU/Linux)
>
> iEYEAREIAAYFAkmJ9VYACgkQU/Z/dHFfxtffTACgk8wMjmW11gLPqckXl/7ILOdU
> y1oAoNp/vodkn1b1UO+MvbXVQaFjvZry
> =rco6
> -----END PGP SIGNATURE-----
>
> _______________________________________________
> Devl mailing list
> [email protected]
> http://emu.freenetproject.org/cgi-bin/mailman/listinfo/devl
>
_______________________________________________
Devl mailing list
[email protected]
http://emu.freenetproject.org/cgi-bin/mailman/listinfo/devl

Reply via email to