Implement locks to hopefully resolve race conditions with I/O - experimental

This commit is contained in:
Luck
2016-10-01 19:03:05 +01:00
Unverified
parent b5ece8b5bd
commit 4787361e66
22 changed files with 1156 additions and 875 deletions
@@ -34,6 +34,8 @@ import me.lucko.luckperms.utils.Identifiable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
@ToString
@EqualsAndHashCode(of = {"name"})
@@ -51,6 +53,9 @@ public class Track implements Identifiable<String> {
*/
private List<String> groups = Collections.synchronizedList(new ArrayList<>());
@Getter
private final Lock ioLock = new ReentrantLock();
@Override
public String getId() {
return name;
@@ -40,18 +40,13 @@ public class TrackManager extends AbstractManager<String, Track> {
.collect(Collectors.toSet());
}
@Override
public void copy(Track from, Track to) {
to.setGroups(from.getGroups());
}
/**
* Makes a new track object
* @param name The name of the track
* @return a new {@link Track} object
*/
@Override
public Track make(String name) {
public Track apply(String name) {
return new Track(name);
}
}