Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removed unnecessary read lock in SpongeScheduler #3832

Merged
merged 1 commit into from
Apr 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public abstract class SpongeScheduler implements Scheduler {
private final String tag;

// The simple queue of all pending (and running) ScheduledTasks
protected final Map<UUID, SpongeScheduledTask> tasks = new ConcurrentHashMap<>();
private final Map<UUID, SpongeScheduledTask> tasks = new ConcurrentHashMap<>();
private long sequenceNumber = 0L;

SpongeScheduler(final String tag) {
Expand Down Expand Up @@ -107,9 +107,7 @@ private void removeTask(final SpongeScheduledTask task) {
@Override
public Optional<ScheduledTask> findTask(final UUID id) {
Objects.requireNonNull(id, "id");
synchronized (this.tasks) {
return Optional.ofNullable(this.tasks.get(id));
}
return Optional.ofNullable(this.tasks.get(id));
}

@Override
Expand All @@ -130,9 +128,7 @@ public Set<ScheduledTask> findTasks(final String pattern) {

@Override
public Set<ScheduledTask> tasks() {
synchronized (this.tasks) {
return Sets.newHashSet(this.tasks.values());
}
return Sets.newHashSet(this.tasks.values());
}

@Override
Expand Down