
io.jsync.shareddata.SharedData Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jsync.io Show documentation
Show all versions of jsync.io Show documentation
jsync.io is a non-blocking, event-driven networking framework for Java
/*
* Copyright (c) 2011-2013 The original author or authors
* ------------------------------------------------------
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Apache License v2.0 which accompanies this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* The Apache License v2.0 is available at
* http://www.opensource.org/licenses/apache2.0.php
*
* You may elect to redistribute this code under either of these licenses.
*/
package io.jsync.shareddata;
import io.jsync.logging.Logger;
import io.jsync.logging.impl.LoggerFactory;
import io.jsync.shareddata.impl.SharedMap;
import io.jsync.shareddata.impl.SharedSet;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
/**
* Sometimes it is desirable to share immutable data between different event loops, for example to implement a
* cache of data.
* This class allows instances of shared data structures to be looked up and used from different event loops.
* The data structures themselves will only allow certain data types to be stored into them. This shields you from
* worrying about any thread safety issues might occur if mutable objects were shared between event loops.
* The following types can be stored in a shareddata data structure:
*
* {@link String}
* {@link Integer}
* {@link Long}
* {@link Double}
* {@link Float}
* {@link Short}
* {@link Byte}
* {@link Character}
* {@code byte[]} - this will be automatically copied, and the copy will be stored in the structure.
* {@link io.jsync.buffer.Buffer} - this will be automatically copied, and the copy will be stored in the
* structure.
*
*
*
* Instances of this class are thread-safe.
*
* @author Tim Fox
*/
public class SharedData {
private static final Logger log = LoggerFactory.getLogger(SharedData.class);
private ConcurrentMap
© 2015 - 2025 Weber Informatics LLC | Privacy Policy