Merged gcj-eclipse branch to trunk.

From-SVN: r120621
This commit is contained in:
Tom Tromey 2007-01-09 19:58:05 +00:00
parent c648dedbde
commit 97b8365caf
17478 changed files with 606493 additions and 100744 deletions

View file

@ -306,50 +306,50 @@ public class Timer
// 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;
}
}
}
{
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;
newLen /= 2;
if (newLen != heap.length)
{
TimerTask[] newHeap = new TimerTask[newLen];
System.arraycopy(heap, 0, newHeap, 0, elements + 1);
heap = newHeap;
}
{
TimerTask[] newHeap = new TimerTask[newLen];
System.arraycopy(heap, 0, newHeap, 0, elements + 1);
heap = newHeap;
}
return removed;
}
} // TaskQueue
@ -474,11 +474,11 @@ public class Timer
this(daemon, Thread.NORM_PRIORITY);
}
/**
/**
* Create a new Timer whose Thread has the indicated name. It will have
* normal priority and will not be a daemon thread.
* @param name the name of the Thread
* @since 1.5
* @since 1.5
*/
public Timer(String name)
{
@ -691,7 +691,7 @@ public class Timer
{
queue.setNullOnEmpty(true);
}
/**
* Removes all cancelled tasks from the queue.
* @return the number of tasks removed