1 11 package org.eclipse.debug.internal.ui.viewers; 12 13 import org.eclipse.core.runtime.jobs.ISchedulingRule; 14 15 20 public class AsynchronousSchedulingRuleFactory { 21 22 private static AsynchronousSchedulingRuleFactory fgFactory = null; 23 24 27 class SerialRule implements ISchedulingRule { 28 29 public SerialRule() { 30 } 31 32 public boolean contains(ISchedulingRule rule) { 33 return rule == this; 34 } 35 36 public boolean isConflicting(ISchedulingRule rule) { 37 return rule instanceof SerialRule; 38 } 39 } 40 41 class SerialPerObjectRule implements ISchedulingRule { 42 43 private Object fObject = null; 44 45 public SerialPerObjectRule(Object lock) { 46 fObject = lock; 47 } 48 49 52 public boolean contains(ISchedulingRule rule) { 53 return rule == this; 54 } 55 56 59 public boolean isConflicting(ISchedulingRule rule) { 60 if (rule instanceof SerialPerObjectRule) { 61 SerialPerObjectRule vup = (SerialPerObjectRule) rule; 62 return fObject == vup.fObject; 63 } 64 return false; 65 } 66 67 } 68 69 private AsynchronousSchedulingRuleFactory() {} 70 71 public static AsynchronousSchedulingRuleFactory getDefault() { 72 if (fgFactory == null) { 73 fgFactory = new AsynchronousSchedulingRuleFactory(); 74 } 75 return fgFactory; 76 } 77 78 84 public ISchedulingRule newSerialRule() { 85 return new SerialRule(); 86 } 87 88 95 public ISchedulingRule newSerialPerObjectRule(Object lock) { 96 return new SerialPerObjectRule(lock); 97 } 98 99 } 100 | Popular Tags |