mirror of
https://github.com/corda/corda.git
synced 2025-06-13 12:48:18 +00:00
implement ConcurrentHashMap and AtomicReferenceArray
This is the simplest possible ConcurrentHashMap I could come up with that works and is actually concurrent in the way one would expect. It's pretty unconventional, being based on a persistent red-black tree, and not particularly memory-efficient or cache-friendly. I think this is a good place to start, though, and it should perform reasonably well for most workloads. Patches for a more efficient implementation are welcome! I also implemented AtomicReferenceArray, since I was using it in my first, naive attempt to implement ConcurrentHashMap. I had to do a bit of refactoring, including moving some non-standard stuff from java.util.Collections to avian.Data so I could make it available to code outside the java.util package, which is why I had to modify several unrelated files.
This commit is contained in:
23
classpath/java/util/concurrent/ConcurrentMap.java
Normal file
23
classpath/java/util/concurrent/ConcurrentMap.java
Normal file
@ -0,0 +1,23 @@
|
||||
/* Copyright (c) 2008-2014, Avian Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software
|
||||
for any purpose with or without fee is hereby granted, provided
|
||||
that the above copyright notice and this permission notice appear
|
||||
in all copies.
|
||||
|
||||
There is NO WARRANTY for this software. See license.txt for
|
||||
details. */
|
||||
|
||||
package java.util.concurrent;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface ConcurrentMap<K,V> extends Map<K,V> {
|
||||
public V putIfAbsent(K key, V value);
|
||||
|
||||
public boolean remove(K key, V value);
|
||||
|
||||
public V replace(K key, V value);
|
||||
|
||||
public boolean replace(K key, V oldValue, V newValue);
|
||||
}
|
Reference in New Issue
Block a user