예제 #1
0
 public void add(Object atom) {
   synchronized (buckets) {
     if (pos >= bucket_size || buckets.size() == 0) {
       buckets.put(new Object[bucket_size]);
       pos = 0;
     }
     buckets.peekBack()[pos++] = atom;
   }
 }
예제 #2
0
 public void memoryUsageLow(long usedMemory, long maxMemory) {
   //			System.out.println("FREE COLD ATOMS START " + Runtime.getRuntime().freeMemory() + " -
   // " + buckets.size());
   synchronized (buckets) {
     int cnt = buckets.size() / evictFactor;
     if (cnt == 0) cnt = buckets.size() > 0 ? 1 : 0;
     while (cnt-- > 0) buckets.fetch();
   }
   // 2012.02.02 System.gc();
   //			System.out.println("FREE COLD ATOMS END " + Runtime.getRuntime().freeMemory() + " - "
   // + buckets.size());
 }
예제 #3
0
 public int size() {
   return bucket_size * buckets.size();
 }
예제 #4
0
 /**
  * @param capacity
  * @param bucket_size
  */
 public ColdAtoms(int bucket_size) {
   this.bucket_size = bucket_size;
   buckets.put(new Object[bucket_size]);
 }