src/jdk.jfr/share/classes/jdk/jfr/consumer/ConstantLookup.java
author egahlin
Thu, 05 Sep 2019 16:46:50 +0200
branchJEP-349-branch
changeset 58020 f082177c5023
parent 57985 be121cbf3284
child 58112 e7754025004b
permissions -rw-r--r--
Improved handling of Thread.interrupt() + cleanup

package jdk.jfr.consumer;

import jdk.jfr.internal.Type;

final class ConstantLookup {
    private final Type type;
    private ConstantMap current;
    private ConstantMap previous = ConstantMap.EMPTY;

    ConstantLookup(ConstantMap current, Type type) {
        this.current = current;
        this.type = type;
    }

    public Type getType() {
        return type;
    }

    public ConstantMap getLatestPool() {
        return current;
    }

    public void newPool() {
        previous = current;
        current = new ConstantMap(current.factory, current.name);
    }

    public Object getPreviousResolved(long key) {
        return previous.getResolved(key);
    }

    public Object getCurrentResolved(long key) {
        return current.getResolved(key);
    }

    public Object getCurrent(long key) {
        return current.get(key);
    }
}