Closed MrIvanPlays closed 1 year ago
@Jikoo can you review please so we can continue working on v2?
I've thought of migrating the logic from that long-ass chained countdown latch spaghetti to my new Process library. Opinions wanted.
I did a explanation in ArcanePlugins discord when I made the Process library and I'm gonna do a quick rundown here and what is the potential advantage:
Current code relies on at least 1 countdown latch per account (2 latches if the account is a non player one), and a countdown latch for all the account types migrated. Combined with the .thenApply
/.thenCompose
calls on all the futures and stuff is currently a literal spaghetti. Another disadvantage is that the code waits for 1 account to finish migration before proceeding to another account.
With Process we can implement a simple Process
class for player accounts and non player accounts, make x
amount of instances of that implementation and run them in parallel and have it wait (either sync or async) for all of them to finish. Process uses only 1 (!) countdown latch per runProcesses
call, reducing the spaghetti down to nonexistent.
To add to this, since all the migration code is running async I'm pretty sure we're good to replace all the .thenApply
/.thenCompose
spaghetti with simple .get
/.join
calls. My tests conclude they do not swallow exceptions.
That sounds good to me. I think the old Phaser code did run pretty parallel, but it was also an absolute nightmare of back and forth. Honestly, anything to make migration cleaner.
Alright. I think in about 2 hours ill be done implementing it.
taking longer than expected, i have to do a modification to my library
😁 Special thanks to: BetterEconomy v2.6-ivanized running the version of treasury on the latest commit on this branch.
Also a quick clarification: I'm not merging this until we test it.
Waiting for the day When @Jikoo will review this
Tested and works. I'm still waiting @Jikoo
@Jikoo :
Closes #217