Package com.google.common.collect

Examples of com.google.common.collect.MapMaker$StrongValueReference


    private final ReentrantReadWriteLock dumpLock;

    public CategoryMaskManager(ReentrantReadWriteLock dumpLock) {
        this.nextbit = new AtomicInteger(0);
        this.categoryInfoMap = new MapMaker().makeMap();
        this.dumpLock = dumpLock;
    }
View Full Code Here


  }

  @Test
  public void testWeakRefsMap() throws Exception {

    ConcurrentMap<String, Object> objects = new MapMaker().weakValues()
        .makeMap();

    objects.put("xxx", new Object());

    if (null == objects.get("xxx")) {
View Full Code Here

    @Inject StateCache(@SlobLocalCacheExpirationMillis int expirationMillis) {
      // See commit ebb4736368b6d371a1bf5005541d96b88dcac504 for my failed attempt
      // at using CacheBuilder.  TODO(ohler): Figure out the right solution to this.
      @SuppressWarnings("deprecation")
      Map<Pair<String, SlobId>, CacheEntry> currentStates = new MapMaker()
          .softValues()
          .expireAfterAccess(expirationMillis, TimeUnit.MILLISECONDS)
          .makeMap();
      this.currentStates = currentStates;
    }
View Full Code Here

    private static Set<Object> newStrongSet(final int expectedMaxSize) {
      return newSetFromMap(new IdentityHashMap<Object, Boolean>(expectedMaxSize));
    }

    private static Set<Object> newWeakSet() {
      return newSetFromMap(new MapMaker().concurrencyLevel(WRITE_CONCURRENCY).weakKeys().<Object, Boolean> makeMap());
    }
View Full Code Here

    private Integer _singleContextId;

    public ContextIdReference(final T reference, final ReferenceQueue<? super T> queue) {
        super(reference, queue);
        if (Constants.useMultipleContexts) {
            _idCache = new MapMaker().initialCapacity(2).weakKeys().makeMap();
        } else {
            _idCache = null;
        }
        REFS.add(this);
    }
View Full Code Here

        if (vboId == 0) {
            throw new IllegalArgumentException("vboId must != 0");
        }

        if (_vboIdCache == null) {
            _vboIdCache = new MapMaker().initialCapacity(1).weakKeys().makeMap();
        }
        _vboIdCache.put(glContext, vboId);
    }
View Full Code Here

    public void setRenderDelegate(final RenderDelegate delegate, final Object glContextRef) {
        if (_delegateMap == null) {
            if (delegate == null) {
                return;
            } else {
                _delegateMap = new MapMaker().weakKeys().makeMap();
            }
        }
        if (delegate != null) {
            if (glContextRef == null) {
                _delegateMap.put(defaultDelegateRef, delegate);
View Full Code Here

    protected Map<ClientIdentity, Position>                  cursors;

    public void start() {
        super.start();

        batches = new MapMaker().makeComputingMap(new Function<ClientIdentity, MemoryClientIdentityBatch>() {

            public MemoryClientIdentityBatch apply(ClientIdentity clientIdentity) {
                return MemoryClientIdentityBatch.create(clientIdentity);
            }

        });

        cursors = new MapMaker().makeMap();

        destinations = new MapMaker().makeComputingMap(new Function<String, List<ClientIdentity>>() {

            public List<ClientIdentity> apply(String destination) {
                return Lists.newArrayList();
            }
        });
View Full Code Here

        if (!dataDir.canRead() || !dataDir.canWrite()) {
            throw new CanalMetaManagerException("dir[" + dataDir.getPath() + "] can not read/write");
        }

        dataFileCaches = new MapMaker().makeComputingMap(new Function<String, File>() {

            public File apply(String destination) {
                return getDataFile(destination);
            }
        });

        executor = Executors.newScheduledThreadPool(1);
        destinations = new MapMaker().makeComputingMap(new Function<String, List<ClientIdentity>>() {

            public List<ClientIdentity> apply(String destination) {
                return loadClientIdentiry(destination);
            }
        });

        cursors = new MapMaker().makeComputingMap(new Function<ClientIdentity, Position>() {

            public Position apply(ClientIdentity clientIdentity) {
                Position position = loadCursor(clientIdentity.getDestination(), clientIdentity);
                if (position == null) {
                    return nullCursor; // 返回一个空对象标识,避免出现异常
                } else {
                    return position;
                }
            }
        });

        batches = new MapMaker().makeComputingMap(new Function<ClientIdentity, MemoryClientIdentityBatch>() {

            public MemoryClientIdentityBatch apply(ClientIdentity clientIdentity) {
                // 读取一下zookeeper信息,初始化一次
                return loadBatch(clientIdentity.getDestination(), clientIdentity);
            }
View Full Code Here

    public BaseRepository getBaseRepository() {
        return this;
    }

    private MapMaker cacheMapMaker(CachePolicy cachePolicy) {
        MapMaker mapMaker = new MapMaker();
        switch (cachePolicy) {
        case STRONG:
            break;
        case SOFT:
            mapMaker.softValues();
            break;
        case WEAK:
            mapMaker.weakValues();
            break;
        case NONE:
            // Consider not to have any map at all
            mapMaker.maximumSize(0);
            break;
        }
        return mapMaker;
    }
View Full Code Here

TOP

Related Classes of com.google.common.collect.MapMaker$StrongValueReference

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.