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:
Paldiu
2022-07-07 23:09:25 -05:00
commit 115e8fcb20
17 changed files with 714 additions and 0 deletions

View 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);
}
}