Return-Path: Delivered-To: apmail-incubator-river-dev-archive@minotaur.apache.org Received: (qmail 62792 invoked from network); 18 Jul 2010 19:16:49 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 18 Jul 2010 19:16:49 -0000 Received: (qmail 32373 invoked by uid 500); 18 Jul 2010 19:16:49 -0000 Delivered-To: apmail-incubator-river-dev-archive@incubator.apache.org Received: (qmail 32335 invoked by uid 500); 18 Jul 2010 19:16:49 -0000 Mailing-List: contact river-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: river-dev@incubator.apache.org Delivered-To: mailing list river-dev@incubator.apache.org Received: (qmail 32326 invoked by uid 99); 18 Jul 2010 19:16:49 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 18 Jul 2010 19:16:48 +0000 X-ASF-Spam-Status: No, hits=0.7 required=10.0 tests=RCVD_IN_DNSWL_NONE,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [61.9.168.137] (HELO nskntmtas01p.mx.bigpond.com) (61.9.168.137) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 18 Jul 2010 19:16:40 +0000 Received: from nskntotgx03p.mx.bigpond.com ([61.9.223.241]) by nskntmtas01p.mx.bigpond.com with ESMTP id <20100718191605.FJM13611.nskntmtas01p.mx.bigpond.com@nskntotgx03p.mx.bigpond.com> for ; Sun, 18 Jul 2010 19:16:05 +0000 Received: from [10.1.1.2] (really [61.9.223.241]) by nskntotgx03p.mx.bigpond.com with ESMTP id <20100718191604.BVAX13584.nskntotgx03p.mx.bigpond.com@[10.1.1.2]> for ; Sun, 18 Jul 2010 19:16:04 +0000 Message-ID: <4C43523E.7050706@zeus.net.au> Date: Mon, 19 Jul 2010 05:13:02 +1000 From: Peter Firmstone User-Agent: Thunderbird 2.0.0.14 (X11/20080531) MIME-Version: 1.0 To: river-dev@incubator.apache.org Subject: Re: TaskManager requirements References: <4C427155.9000801@acm.org> In-Reply-To: <4C427155.9000801@acm.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-RPD-ScanID: Class unknown; VirusThreatLevel unknown, RefID str=0001.0A090207.4C4352F4.01DF,ss=1,fgs=0 X-Virus-Checked: Checked by ClamAV on apache.org Patricia Shanahan wrote: > I have questions about the TaskManager remove(Task) method. Trying to > end work by any means other than run to completion is always a bit > tricky. > > In the event of a remove call for an active Task, TaskManager issues > an interrupt unless the call is in the task's thread. It also removes > the Task from its bookkeeping. > > In the current implementation, removal from the ArrayList immediately > stops the removed task from blocking later tasks that need to runAfter > it. That can let a dependent task start running before the removed > task notices the interrupt. That could be bad if, for example, they > share data that is being protected through the runAfter system. Perhaps a hashmap might be used to store tasks that are pending removal, so they can be left on the queue until the removed task has been interrupted? > > It will get worse in any performance improved TaskManager. One of the > performance issues is a tendency to use only one thread, regardless of > the number of runnable tasks or the constructor parameters, if there > are a lot of runAfter dependencies. I plan to fix that so that the > number of threads will be in accordance with the constructor parameters. > > The other issue is that a task that ignores the interrupt can keep > possession of its thread, indefinitely, despite a remove call. Since > we only create a bounded number of threads, that could effectively > kill the TaskManager. To what extent are TaskManager instances shared > by tasks whose run methods don't have the same trust characteristics? Currently TaskManager is only used internally, so the trust should be the same between tasks, although I like the idea of a singleton TaskManager and did mention it earlier, that doesn't suit the current implementation. We could put an AccessController permission check in TaskManager before a task is placed into the queue? > > Patricia >