Skyblocker icon indicating copy to clipboard operation
Skyblocker copied to clipboard

Improve `Scheduler` safety

Open AzureAaron opened this issue 10 months ago • 1 comments

Describe the new feature.

Scheduling tasks with the Scheduler outside of the Render Thread should hard fail with an exception otherwise it could introduce hard to debug CMEs if a task is scheduled while the scheduler is being ticked. Currently to my knowledge only the API authentication does off-thread task scheduling.

Additionally scheduling a null task should fail with an NPE and the Preconditions class should be used to ensure tasks aren't being scheduled in the past and whatnot.

The migration path for any off-thread scheduling is just to wrap it in a client#send call like so: client.send(() -> Scheduler.INSTANCE.schedule(...)).

These changes will decrease the likelihood of the Scheduler being used improperly.

Images

No response

AzureAaron avatar Feb 17 '25 04:02 AzureAaron

Partially fixed in #1306 as it now just runs everything on the render thread automatically but this should still be enforced later.

AzureAaron avatar Jun 05 '25 19:06 AzureAaron