forked from StarOpenSource/Engine
Add synchronized keyword to various methods
This commit is contained in:
parent
76b2a08804
commit
d3b09848b6
7 changed files with 23 additions and 23 deletions
|
@ -343,7 +343,7 @@ public final class Engine implements SubsystemMainClass {
|
|||
* @param exitCode code to exit with, from 0-255
|
||||
* @since 1-alpha0
|
||||
*/
|
||||
public void shutdown(@Range(from = 0, to = 255) int exitCode) {
|
||||
public synchronized void shutdown(@Range(from = 0, to = 255) int exitCode) {
|
||||
logger.info("Shutting engine down");
|
||||
shuttingDown = true;
|
||||
|
||||
|
@ -379,7 +379,7 @@ public final class Engine implements SubsystemMainClass {
|
|||
*
|
||||
* @since 1-alpha0
|
||||
*/
|
||||
public void shutdown() {
|
||||
public synchronized void shutdown() {
|
||||
shutdown(0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -271,7 +271,7 @@ public final class EngineConfiguration implements SubsystemConfiguration {
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public void loadConfiguration(@NotNull Properties properties) {
|
||||
public synchronized void loadConfiguration(@NotNull Properties properties) {
|
||||
// Define variables
|
||||
PropertyParser parser = new PropertyParser(properties);
|
||||
|
||||
|
@ -318,12 +318,12 @@ public final class EngineConfiguration implements SubsystemConfiguration {
|
|||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public void loadConfiguration() {
|
||||
public synchronized void loadConfiguration() {
|
||||
loadConfiguration(System.getProperties());
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public void loadDefaultConfiguration() {
|
||||
public synchronized void loadDefaultConfiguration() {
|
||||
debug = false;
|
||||
debugEvents = false;
|
||||
debugShortcodeConverter = false;
|
||||
|
|
|
@ -158,7 +158,7 @@ public class EventHelper {
|
|||
* @param clazz event listeners to (p)recompute, set to {@code null} to recompute all cached events
|
||||
* @since 1-alpha0
|
||||
*/
|
||||
public static void precomputeEventListeners(@Nullable Class<? extends Event> clazz) {
|
||||
public static synchronized void precomputeEventListeners(@Nullable Class<? extends Event> clazz) {
|
||||
if (clazz == null)
|
||||
for (Class<? extends Event> event : cachedEventListeners.keySet())
|
||||
precomputeEventListeners(event);
|
||||
|
@ -178,7 +178,7 @@ public class EventHelper {
|
|||
* @param clazz event class to remove cached event listeners for or {@code null} to remove all cached event listeners
|
||||
* @since 1-alpha0
|
||||
*/
|
||||
public static void removePrecomputedEventListeners(@Nullable Class<? extends Event> clazz) {
|
||||
public static synchronized void removePrecomputedEventListeners(@Nullable Class<? extends Event> clazz) {
|
||||
if (clazz == null)
|
||||
cachedEventListeners.clear();
|
||||
else
|
||||
|
|
|
@ -366,7 +366,7 @@ public final class EngineInformation {
|
|||
*
|
||||
* @since 1-alpha1
|
||||
*/
|
||||
public static void updateVariables() {
|
||||
public static synchronized void updateVariables() {
|
||||
LoggerInstance logger = new LoggerInstance(new LogIssuer(EngineInformation.class, CodePart.ENGINE));
|
||||
|
||||
// Load properties from bundled gradle.properties
|
||||
|
|
|
@ -109,7 +109,7 @@ public final class CrashHandler {
|
|||
* @param throwable simply to provide stacktrace and further insight into the crash, can be set to {@code null}
|
||||
* @since 1-alpha0
|
||||
*/
|
||||
public static void handleCrash(@NotNull LogIssuer logIssuer, @NotNull String message, @Nullable Throwable throwable) {
|
||||
public static synchronized void handleCrash(@NotNull LogIssuer logIssuer, @NotNull String message, @Nullable Throwable throwable) {
|
||||
String base = crashTemplate;
|
||||
|
||||
// Replace '%content%' with crash content
|
||||
|
@ -170,7 +170,7 @@ public final class CrashHandler {
|
|||
* But hey, if someone breaks this method (which may be possible idk didn't test it) then congrats!
|
||||
*/
|
||||
@NotNull
|
||||
private static String processCrashContent(@NotNull LinkedHashMap<Object, Object> map, int indentationSize) {
|
||||
private static synchronized String processCrashContent(@NotNull LinkedHashMap<Object, Object> map, int indentationSize) {
|
||||
StringBuilder content = new StringBuilder();
|
||||
|
||||
for (Object key : map.keySet()) {
|
||||
|
@ -217,7 +217,7 @@ public final class CrashHandler {
|
|||
* @return crash content string
|
||||
* @since 1-alpha0
|
||||
*/
|
||||
public static String processCrashContent() {
|
||||
public static synchronized String processCrashContent() {
|
||||
return processCrashContent(crashContent, 0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -177,10 +177,6 @@ public final class Logger {
|
|||
* @since 1-alpha1
|
||||
*/
|
||||
private static void processLogMessage(@NotNull LogIssuer issuer, @NotNull LogLevel level, @NotNull String message) {
|
||||
// Check if level is allowed
|
||||
if (level.compareTo(EngineConfiguration.getInstance().getLoggerLevel()) < 0)
|
||||
return;
|
||||
|
||||
// Evaluate all active rules
|
||||
for (LogRule rule : activeRules) {
|
||||
if (rule.evaluate(issuer, level, message)) {
|
||||
|
@ -234,6 +230,10 @@ public final class Logger {
|
|||
// Check if engine has initialized
|
||||
if (Engine.getInstance() == null) return;
|
||||
|
||||
// Dismiss if level is not allowed
|
||||
if (level.compareTo(EngineConfiguration.getInstance().getLoggerLevel()) < 0)
|
||||
return;
|
||||
|
||||
if (EngineConfiguration.getInstance().isOptimizeLogging())
|
||||
// Optimizations enabled, add to message queue
|
||||
queuedMessages.add(new QueuedLogMessage(issuer, level, message));
|
||||
|
|
|
@ -69,7 +69,7 @@ public final class DependencyResolver {
|
|||
* @return itself
|
||||
* @since 1-alpha1
|
||||
*/
|
||||
public DependencyResolver addVector(@NotNull DependencyVector vector) {
|
||||
public synchronized DependencyResolver addVector(@NotNull DependencyVector vector) {
|
||||
vectors.add(vector);
|
||||
resolved = false;
|
||||
return this;
|
||||
|
@ -82,7 +82,7 @@ public final class DependencyResolver {
|
|||
* @return itself
|
||||
* @since 1-alpha1
|
||||
*/
|
||||
public DependencyResolver addVectors(@NotNull DependencyVector[] vectors) {
|
||||
public synchronized DependencyResolver addVectors(@NotNull DependencyVector[] vectors) {
|
||||
addVectors(Arrays.stream(vectors).toList());
|
||||
resolved = false;
|
||||
return this;
|
||||
|
@ -95,7 +95,7 @@ public final class DependencyResolver {
|
|||
* @return itself
|
||||
* @since 1-alpha1
|
||||
*/
|
||||
public DependencyResolver addVectors(@NotNull Collection<? extends @NotNull DependencyVector> vectors) {
|
||||
public synchronized DependencyResolver addVectors(@NotNull Collection<? extends @NotNull DependencyVector> vectors) {
|
||||
this.vectors.addAll(vectors);
|
||||
resolved = false;
|
||||
return this;
|
||||
|
@ -108,7 +108,7 @@ public final class DependencyResolver {
|
|||
* @return itself
|
||||
* @since 1-alpha1
|
||||
*/
|
||||
public DependencyResolver addVectors(@NotNull List<? extends @NotNull DependencyVector> vectors) {
|
||||
public synchronized DependencyResolver addVectors(@NotNull List<? extends @NotNull DependencyVector> vectors) {
|
||||
this.vectors.addAll(vectors);
|
||||
resolved = false;
|
||||
return this;
|
||||
|
@ -121,7 +121,7 @@ public final class DependencyResolver {
|
|||
* @return itself
|
||||
* @since 1-alpha1
|
||||
*/
|
||||
public DependencyResolver addVectors(@NotNull ImmutableArrayList<? extends @NotNull DependencyVector> vectors) {
|
||||
public synchronized DependencyResolver addVectors(@NotNull ImmutableArrayList<? extends @NotNull DependencyVector> vectors) {
|
||||
this.vectors.addAll(vectors);
|
||||
resolved = false;
|
||||
return this;
|
||||
|
@ -134,7 +134,7 @@ public final class DependencyResolver {
|
|||
* @return itself
|
||||
* @since 1-alpha1
|
||||
*/
|
||||
public DependencyResolver addVectors(@NotNull ImmutableLinkedList<? extends @NotNull DependencyVector> vectors) {
|
||||
public synchronized DependencyResolver addVectors(@NotNull ImmutableLinkedList<? extends @NotNull DependencyVector> vectors) {
|
||||
this.vectors.addAll(vectors);
|
||||
resolved = false;
|
||||
return this;
|
||||
|
@ -147,7 +147,7 @@ public final class DependencyResolver {
|
|||
* @return itself
|
||||
* @since 1-alpha1
|
||||
*/
|
||||
public DependencyResolver addVectors(@NotNull Set<? extends @NotNull DependencyVector> vectors) {
|
||||
public synchronized DependencyResolver addVectors(@NotNull Set<? extends @NotNull DependencyVector> vectors) {
|
||||
this.vectors.addAll(vectors);
|
||||
resolved = false;
|
||||
return this;
|
||||
|
@ -163,7 +163,7 @@ public final class DependencyResolver {
|
|||
* @since 1-alpha1
|
||||
*/
|
||||
@SuppressWarnings("JavaReflectionInvocation")
|
||||
public DependencyResolver resolve() throws UnmetDependenciesException, UnexpectedThrowableException {
|
||||
public synchronized DependencyResolver resolve() throws UnmetDependenciesException, UnexpectedThrowableException {
|
||||
Map<DependencyVector, String> unmetDependencies = new HashMap<>();
|
||||
resolved = false;
|
||||
|
||||
|
|
Loading…
Reference in a new issue