* Daniel Cheng <j16sdiz+freenet at gmail.com> [2009-02-04 23:35:04]:
> On Wed, Feb 4, 2009 at 7:41 PM, Florent Daigniere
> <nextgens at freenetproject.org> wrote:
> > Daniel Cheng wrote:
> >> On Wed, Feb 4, 2009 at 12:45 AM, <nextgens at freenetproject.org> 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?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
URL:
<https://emu.freenetproject.org/pipermail/devl/attachments/20090204/7baef108/attachment.pgp>