Implement locks to hopefully resolve race conditions with I/O - experimental
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user