3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-26 00:00:28 +01:00

Revert unnecessary synchronizes in ListWrapper

Usually the list we're wrapping is synchronized, so instead we'll ensure our code can be run concurrently.

There might be issues with other plugins and this change (but it's unlikely), open a issue if you see any of these after this change.
Dieser Commit ist enthalten in:
Myles 2019-03-17 16:04:13 +00:00
Ursprung d133ca4a0f
Commit ee5eb59e42
2 geänderte Dateien mit 26 neuen und 23 gelöschten Zeilen

Datei anzeigen

@ -22,6 +22,8 @@ import java.util.List;
public class BukkitViaInjector implements ViaInjector { public class BukkitViaInjector implements ViaInjector {
private List<ChannelFuture> injectedFutures = new ArrayList<>(); private List<ChannelFuture> injectedFutures = new ArrayList<>();
private List<Pair<Field, Object>> injectedLists = new ArrayList<>(); private List<Pair<Field, Object>> injectedLists = new ArrayList<>();
private List<ChannelFuture> injectedFutures = new ConcurrentList<>();
private List<Pair<Field, Object>> injectedLists = new ConcurrentList<>();
@Override @Override
public void inject() throws Exception { public void inject() throws Exception {

Datei anzeigen

@ -19,43 +19,44 @@ public abstract class ListWrapper implements List {
} }
@Override @Override
public synchronized int size() { public int size() {
return this.list.size(); return this.list.size();
} }
@Override @Override
public synchronized boolean isEmpty() { public boolean isEmpty() {
return this.list.isEmpty(); return this.list.isEmpty();
} }
@Override @Override
public synchronized boolean contains(Object o) { public boolean contains(Object o) {
return this.list.contains(o); return this.list.contains(o);
} }
@Override @Override
public synchronized Iterator iterator() { public Iterator iterator() {
return listIterator(); return listIterator();
} }
@Override @Override
public synchronized Object[] toArray() { public Object[] toArray() {
return this.list.toArray(); return this.list.toArray();
} }
@Override @Override
public synchronized boolean add(Object o) { public boolean add(Object o) {
handleAdd(o); handleAdd(o);
return this.list.add(o); return this.list.add(o);
} }
@Override @Override
public synchronized boolean remove(Object o) { public boolean remove(Object o) {
return this.list.remove(o); return this.list.remove(o);
} }
@Override @Override
public synchronized boolean addAll(Collection c) { public boolean addAll(Collection c) {
for (Object o : c) { for (Object o : c) {
handleAdd(o); handleAdd(o);
} }
@ -63,7 +64,7 @@ public abstract class ListWrapper implements List {
} }
@Override @Override
public synchronized boolean addAll(int index, Collection c) { public boolean addAll(int index, Collection c) {
for (Object o : c) { for (Object o : c) {
handleAdd(o); handleAdd(o);
} }
@ -71,72 +72,72 @@ public abstract class ListWrapper implements List {
} }
@Override @Override
public synchronized void clear() { public void clear() {
this.list.clear(); this.list.clear();
} }
@Override @Override
public synchronized Object get(int index) { public Object get(int index) {
return this.list.get(index); return this.list.get(index);
} }
@Override @Override
public synchronized Object set(int index, Object element) { public Object set(int index, Object element) {
return this.list.set(index, element); return this.list.set(index, element);
} }
@Override @Override
public synchronized void add(int index, Object element) { public void add(int index, Object element) {
this.list.add(index, element); this.list.add(index, element);
} }
@Override @Override
public synchronized Object remove(int index) { public Object remove(int index) {
return this.list.remove(index); return this.list.remove(index);
} }
@Override @Override
public synchronized int indexOf(Object o) { public int indexOf(Object o) {
return this.list.indexOf(o); return this.list.indexOf(o);
} }
@Override @Override
public synchronized int lastIndexOf(Object o) { public int lastIndexOf(Object o) {
return this.list.lastIndexOf(o); return this.list.lastIndexOf(o);
} }
@Override @Override
public synchronized ListIterator listIterator() { public ListIterator listIterator() {
return this.list.listIterator(); return this.list.listIterator();
} }
@Override @Override
public synchronized ListIterator listIterator(int index) { public ListIterator listIterator(int index) {
return this.list.listIterator(index); return this.list.listIterator(index);
} }
@Override @Override
public synchronized List subList(int fromIndex, int toIndex) { public List subList(int fromIndex, int toIndex) {
return this.list.subList(fromIndex, toIndex); return this.list.subList(fromIndex, toIndex);
} }
@Override @Override
public synchronized boolean retainAll(Collection c) { public boolean retainAll(Collection c) {
return this.list.retainAll(c); return this.list.retainAll(c);
} }
@Override @Override
public synchronized boolean removeAll(Collection c) { public boolean removeAll(Collection c) {
return this.list.removeAll(c); return this.list.removeAll(c);
} }
@Override @Override
public synchronized boolean containsAll(Collection c) { public boolean containsAll(Collection c) {
return this.list.containsAll(c); return this.list.containsAll(c);
} }
@Override @Override
public synchronized Object[] toArray(Object[] a) { public Object[] toArray(Object[] a) {
return this.list.toArray(a); return this.list.toArray(a);
} }
} }