Yarn: ResourceReloadListener#reload -> createReloadTask or something like that

Created on 22 Oct 2019  ·  3Comments  ·  Source: FabricMC/yarn

ResourceReloadListener#reload is not supposed to perform any reloading on its own. Instead, its goal is to return a CompletableFuture which, when evaluated, is supposed to submit the actual reloading tasks to various Executors.

If you try cheating the system by putting code directly in reload and returning some dummy CompletableFuture that does nothing, the game hangs when reloading, because the future returned by Synchronizer#whenPrepared never gets called.

Naming it something like createReloadTask seems like a way to discourage this path and clarify that no reloading should be done directly in this method.

discussion enhancement refactor

Most helpful comment

imo, ResourceReloadListener should be renamed to ResourceReloader as they are the ones actually performing the reload (compare to ResourceReloadHandler). The reload name is fine imo, or we can consider a consistent naming scheme for all CompletableFuture related names.

All 3 comments

imo, ResourceReloadListener should be renamed to ResourceReloader as they are the ones actually performing the reload (compare to ResourceReloadHandler). The reload name is fine imo, or we can consider a consistent naming scheme for all CompletableFuture related names.

After a look, we already have a resource reloader that monitors reload.

Now, I am a bit confused on what this should be named, or if it should be renamed or not.

Hmm, maybe ResourceReloader -> SimpleResourceReload, ResourceReloadListener -> ResourceReloader. Additionally, name ResourceReloadMonitor to ResourceReload and name the implementations correspondingly. ResourceReload represents one single reload and is discarded immediately after, so this name actually sounds good.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Juuxel picture Juuxel  ·  6Comments

altrisi picture altrisi  ·  4Comments

Boundarybreaker picture Boundarybreaker  ·  3Comments

Awakened-Redstone picture Awakened-Redstone  ·  4Comments

haykam821 picture haykam821  ·  4Comments