コード例 #1
0
 static {
   final String counter = System.getProperty("xbird.counter");
   if ("cliffc".equals(counter)) {
     counterType = CounterType.cliffc;
   } else if ("stripe".equals(counter)) {
     counterType = CounterType.stripe;
   } else if ("stripe2".equals(counter)) {
     counterType = CounterType.stripe2;
   } else if ("stripe3".equals(counter)) {
     counterType = CounterType.stripe3;
   } else if ("atomic".equals(counter)) {
     counterType = CounterType.atomic;
   } else {
     counterType = CounterType.auto;
   }
   int nstripe = Integer.parseInt(Settings.get("xbird.util.counter.nstripe", "-1"));
   if (nstripe == -1) {
     int procs = SystemUtils.availableProcessors();
     nstripe = Math.max(4, procs >> 3); // 4 < x < 8
   }
   NSTRIPE = nstripe;
 }
コード例 #2
0
 public static ICounter createIntCounter(int nstripe) {
   final int procs = SystemUtils.availableProcessors();
   switch (counterType) {
     case cliffc:
       return new HighScalableIntCounter();
     case stripe:
       return new StripeAtomicIntCounter(nstripe);
     case stripe2:
       return new StripeAtomicIntCounter2(nstripe);
     case stripe3:
       return new StripeAtomicIntCounter3(nstripe);
     case atomic:
       return new AtomicIntCounter();
     case auto:
     default:
       if (procs > 64) {
         return new HighScalableIntCounter();
       } else if (procs > 32) {
         return new StripeAtomicIntCounter(nstripe);
       } else {
         return new AtomicIntCounter();
       }
   }
 }