Yep, another cleanup module has arrived to Roblox.
I wrote it, because i couldn’t find a single strictly-typed cleanup module & since i had nothing else to do, I wrote Sweeper.
Feel free to use Sweeper in any projects you are working on, as its under the MIT License.
4 Likes
What’s the difference between this and a Maid module? Looking at the code, they look very similar (one difference I can see is using :RemoveTask
as a way to remove handling/vice executing cleanup functions)
Honestly, I made Sweeper with the idea of it being a faster version of the Maid module.
I wrote it to be a bit more optimized in terms of speed compared to the Maid module from Nevermore. It figures out the type of each task when it’s added, instead of slowing down the cleanup process when there are a bunch of tasks to clean up.
Also, one thing that always bugged me with Maid was having to pass a function to close a thread when I needed to clean it up. With Sweeper, that’s handled for you, which is a nice bonus. No lua-promise support, though.
I might aswell try to do a little benchmark for speed, no idea if it’ll actually be faster though.
edit: I tested both Sweeper and Maid with all the task types that Sweeper supports. For closing threads with Maid, I just passed it a function that runs coroutine.close
on the task. I gave each one 1024 tasks, with an even split of 256 tasks per type.
Performance-wise, they’re pretty much the same. Sometimes one is faster than the other by less than 0.01 seconds, but it’s not a huge difference.