mirror of
https://github.com/SimplexDevelopment/SimplexSS.git
synced 2025-07-12 11:48:34 +00:00
SimplexSS (Scheduling Service)
A reactive non-blocking api for scheduling runnable tasks (now called Services) using Reactor (https://reactorproject.io)
This commit is contained in:
56
src/main/java/io/github/simplex/simplexss/ServicePool.java
Normal file
56
src/main/java/io/github/simplex/simplexss/ServicePool.java
Normal file
@ -0,0 +1,56 @@
|
||||
package io.github.simplex.simplexss;
|
||||
|
||||
import io.github.simplex.api.Service;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
public final class ServicePool {
|
||||
private final Set<Service> associatedServices;
|
||||
private boolean delayed = false;
|
||||
private boolean repeating = false;
|
||||
|
||||
public ServicePool() {
|
||||
this.associatedServices = new HashSet<>();
|
||||
}
|
||||
|
||||
public void setDelayed(boolean delayed) {
|
||||
this.delayed = delayed;
|
||||
}
|
||||
|
||||
public void setRepeating(boolean repeating) {
|
||||
this.repeating = repeating;
|
||||
}
|
||||
|
||||
public boolean isPoolDelayed() {
|
||||
return delayed;
|
||||
}
|
||||
|
||||
public boolean isPoolRepeating() {
|
||||
return repeating;
|
||||
}
|
||||
|
||||
public void addService(Service service) {
|
||||
getAssociatedServices().add(service);
|
||||
}
|
||||
|
||||
public boolean isValidService(Service service) {
|
||||
return getAssociatedServices().contains(service);
|
||||
}
|
||||
|
||||
public Set<Service> getAssociatedServices() {
|
||||
return associatedServices;
|
||||
}
|
||||
|
||||
public Service getService(int serviceID) {
|
||||
return getAssociatedServices()
|
||||
.stream()
|
||||
.filter(s -> s.getServiceID() == serviceID)
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
public void removeService(Service service) {
|
||||
getAssociatedServices().remove(service);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user