dorkbox.messagebus.common.ClassTree Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of MessageBus Show documentation
Show all versions of MessageBus Show documentation
Lightweight, extremely fast, and zero-gc message/event bus for Java 8+
/*
* Copyright 2015 dorkbox, llc
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package dorkbox.messagebus.common;
import com.esotericsoftware.kryo.util.IdentityMap;
import dorkbox.messagebus.util.FastThreadLocal;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
/**
* Simple tree structure that is a map that contains a chain of keys to publish to a value.
*
*
* This Tree store "message classes" as the key, and a unique object as the "value". This map is NEVER cleared (shutdown clears it), and
* the "value" object is used to store/lookup in another map
*
* This data structure is used to keep track of multi-messages - where there is more that one parameter for publish().
*
* @author dorkbox, llc
* Date: 2/2/15
*/
public class ClassTree {
public static int INITIAL_SIZE = 4;
public static float LOAD_FACTOR = 0.8F;
private static
final FastThreadLocal keyCache = new FastThreadLocal() {
@Override
public
IdentityMap initialValue() {
return new IdentityMap(INITIAL_SIZE, LOAD_FACTOR);
}
};
private static
final FastThreadLocal valueCache = new FastThreadLocal();
private AtomicReference
© 2015 - 2025 Weber Informatics LLC | Privacy Policy