[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [cp-patches] [generics] Patch: FYI: update Timer
From: |
Andrew John Hughes |
Subject: |
RE: [cp-patches] [generics] Patch: FYI: update Timer |
Date: |
Sun, 14 Aug 2005 21:05:10 +0100 |
On Sun, 2005-08-14 at 08:30 +0200, Jeroen Frijters wrote:
> Hi Tom,
>
> Why are you checking this into the generics branch? I was under the
> impression that 1.5 functionality could also be applied to the main
> branch, as long as it doesn't require any 1.5 language features.
>
> Regards,
> Jeroen
>
> > -----Original Message-----
> > From: address@hidden
> > [mailto:address@hidden
> > On Behalf Of Tom Tromey
> > Sent: Sunday, August 14, 2005 02:50
> > To: address@hidden
> > Subject: [cp-patches] [generics] Patch: FYI: update Timer
> >
> > I'm checking this in on the generics branch.
> >
> > This adds the new 1.5 methods to java.util.Timer.
> >
> > Tom
> >
> > Index: ChangeLog
> > from Tom Tromey <address@hidden>
> > * java/util/Timer.java (Timer(String)): New constructor.
> > (Timer(String,boolean)): Likewise.
> > (purge): New method.
> > (TaskQueue.purge): Likewise.
> >
> > Index: java/util/Timer.java
> > ===================================================================
> > RCS file: /cvsroot/classpath/classpath/java/util/Timer.java,v
> > retrieving revision 1.11.2.4
> > diff -u -r1.11.2.4 Timer.java
> > --- java/util/Timer.java 2 Aug 2005 20:12:30 -0000 1.11.2.4
> > +++ java/util/Timer.java 14 Aug 2005 00:52:55 -0000
> > @@ -1,5 +1,5 @@
> > /* Timer.java -- Timer that runs TimerTasks at a later time.
> > - Copyright (C) 2000, 2001 Free Software Foundation, Inc.
> > + Copyright (C) 2000, 2001, 2005 Free Software Foundation, Inc.
> >
> > This file is part of GNU Classpath.
> >
> > @@ -297,12 +297,67 @@
> > this.notify();
> > }
> >
> > + /**
> > + * Remove all canceled tasks from the queue.
> > + */
> > + public synchronized int purge()
> > + {
> > + int removed = 0;
> > + // Null out any elements that are canceled. Skip element 0 as
> > + // it is the sentinel.
> > + for (int i = elements; i > 0; --i)
> > + {
> > + if (heap[i].scheduled < 0)
> > + {
> > + ++removed;
> > +
> > + // Remove an element by pushing the appropriate child
> > + // into place, and then iterating to the bottom of the
> > + // tree.
> > + int index = i;
> > + while (heap[index] != null)
> > + {
> > + int child = 2 * index;
> > + if (child >= heap.length)
> > + {
> > + // Off end; we're done.
> > + heap[index] = null;
> > + break;
> > + }
> > +
> > + if (child + 1 >= heap.length || heap[child +
> > 1] == null)
> > + {
> > + // Nothing -- we're done.
> > + }
> > + else if (heap[child] == null
> > + || (heap[child].scheduled
> > + > heap[child + 1].scheduled))
> > + ++child;
> > + heap[index] = heap[child];
> > + index = child;
> > + }
> > + }
> > + }
> > +
> > + // Make a new heap if we shrank enough.
> > + int newLen = heap.length;
> > + while (elements - removed + DEFAULT_SIZE / 2 <= newLen / 4)
> > + newLen /= 2;
> > + if (newLen != heap.length)
> > + {
> > + TimerTask[] newHeap = new TimerTask[newLen];
> > + System.arraycopy(heap, 0, newHeap, 0, elements + 1);
> > + heap = newHeap;
> > + }
> > +
> > + return removed;
> > + }
> > } // TaskQueue
> >
> > /**
> > * The scheduler that executes all the tasks on a
> > particular TaskQueue,
> > * reschedules any repeating tasks and that waits when no
> > task has to be
> > - * executed immediatly. Stops running when canceled or
> > when the parent
> > + * executed immediately. Stops running when canceled or
> > when the parent
> > * Timer has been finalized and no more tasks have to be executed.
> > */
> > private static final class Scheduler implements Runnable
> > @@ -419,6 +474,18 @@
> > this(daemon, Thread.NORM_PRIORITY);
> > }
> >
> > + /** @since 1.5 */
> > + public Timer(String name)
> > + {
> > + this(false, Thread.NORM_PRIORITY, name);
> > + }
> > +
> > + /** @since 1.5 */
> > + public Timer(String name, boolean daemon)
> > + {
> > + this(daemon, Thread.NORM_PRIORITY, name);
> > + }
> > +
> > /**
> > * Creates a new Timer with a daemon Thread as scheduler
> > if daemon is true,
> > * with the priority given and a default name.
> > @@ -611,5 +678,11 @@
> > protected void finalize() throws Throwable
> > {
> > queue.setNullOnEmpty(true);
> > + }
> > +
> > + /** @since 1.5 */
> > + public int purge()
> > + {
> > + return queue.purge();
> > }
> > }
> >
> >
> > _______________________________________________
> > Classpath-patches mailing list
> > address@hidden
> > http://lists.gnu.org/mailman/listinfo/classpath-patches
> >
>
>
> _______________________________________________
> Classpath-patches mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/classpath-patches
>
FWIW, these are my thoughts too.
--
Andrew :-)
Please avoid sending me Microsoft Office (e.g. Word, PowerPoint)
attachments.
See http://www.fsf.org/philosophy/no-word-attachments.html
No software patents in Europe -- http://nosoftwarepatents.com
"Value your freedom, or you will lose it, teaches history.
`Don't bother us with politics' respond those who don't want to learn."
-- Richard Stallman
Escape the Java Trap with GNU Classpath!
http://www.gnu.org/philosophy/java-trap.html
public class gcj extends Freedom implements Java { ... }
signature.asc
Description: This is a digitally signed message part