Your browser does not support JavaScript and this site utilizes JavaScript to build content and provide links to additional information. You should either enable JavaScript in your browser settings or use a browser that supports JavaScript in order to take full advantage of this site.
1 11 package org.eclipse.core.internal.jobs; 12 13 import org.eclipse.core.runtime.*; 14 15 19 public class JobQueue { 20 24 private final InternalJob dummy; 25 26 31 private boolean allowConflictOvertaking; 32 33 36 public JobQueue(boolean allowConflictOvertaking) { 37 dummy = new InternalJob("Queue-Head") { public IStatus run(IProgressMonitor m) { 40 return Status.OK_STATUS; 41 } 42 }; 43 dummy.setNext(dummy); 44 dummy.setPrevious(dummy); 45 this.allowConflictOvertaking = allowConflictOvertaking; 46 } 47 48 51 public void clear() { 52 dummy.setNext(dummy); 53 dummy.setPrevious(dummy); 54 } 55 56 59 public InternalJob dequeue() { 60 InternalJob toRemove = dummy.previous(); 61 if (toRemove == dummy) 62 return null; 63 return toRemove.remove(); 64 } 65 66 69 public void enqueue(InternalJob newEntry) { 70 Assert.isTrue(newEntry.next() == null); 72 Assert.isTrue(newEntry.previous() == null); 73 InternalJob tail = dummy.next(); 74 while (tail != dummy && tail.compareTo(newEntry) < 0 && (allowConflictOvertaking || !newEntry.isConflicting(tail))) 76 tail = tail.next(); 77 final InternalJob tailPrevious = tail.previous(); 79 newEntry.setNext(tail); 80 newEntry.setPrevious(tailPrevious); 81 tailPrevious.setNext(newEntry); 82 tail.setPrevious(newEntry); 83 } 84 85 88 public void remove(InternalJob toRemove) { 89 toRemove.remove(); 90 } 92 93 97 public void resort(InternalJob entry) { 98 remove(entry); 99 enqueue(entry); 100 } 101 102 105 public boolean isEmpty() { 106 return dummy.next() == dummy; 107 } 108 109 112 public InternalJob peek() { 113 return dummy.previous() == dummy ? null : dummy.previous(); 114 } 115 } 116
| Popular Tags
|