Fix splash screen freezing when workers are busy
This commit is contained in:
parent
c861870306
commit
9f112f2fbc
|
|
@ -19,12 +19,19 @@ public class SyncExecutorMixin {
|
||||||
/**
|
/**
|
||||||
* Currently FML spins in driveOne while waiting for the modloading workers. We can improve this
|
* Currently FML spins in driveOne while waiting for the modloading workers. We can improve this
|
||||||
* by sleeping for 50ms at a time.
|
* by sleeping for 50ms at a time.
|
||||||
|
*
|
||||||
|
* Also, render FML splash screen <i>unless</i> there was a new task, rather than only when there was a new task
|
||||||
* @author embeddedt
|
* @author embeddedt
|
||||||
* @reason improve CPU efficiency
|
* @reason improve CPU efficiency
|
||||||
*/
|
*/
|
||||||
@Inject(method = "driveOne", at = @At("HEAD"), remap = false)
|
@Overwrite(remap = false)
|
||||||
private void sleepWhileNoTasks(CallbackInfoReturnable<Boolean> cir) {
|
public boolean driveOne() {
|
||||||
if(tasks.isEmpty())
|
final Runnable task = tasks.pollFirst();
|
||||||
|
if (task != null) {
|
||||||
|
task.run();
|
||||||
|
} else {
|
||||||
LockSupport.parkNanos(PARK_TIME);
|
LockSupport.parkNanos(PARK_TIME);
|
||||||
|
}
|
||||||
|
return task == null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user