Skip to content

Scheduler

About

The Scheduler is what Tome uses to dispose of objects on an in-order basis.


How does it work?

Objects can be passed in with Tome.schedule or unscheduled with Tome.unschedule. When scheduling an object, it's usually given a life time. Tome will wait until that life time has elapsed and destroy the object.

The Scheduler uses a priority queue to keep track of which objects to destroy first. This means upserts, downserts, pushes and pops are O(log n) time complexity.


Why use it?

The Scheduler was made as a more performant replacement for Debris. A Roblox staff member has already mentioned that the service is most likely going to be deprecated and that a task.delay solution is more performant.

As mentioned above, the Scheduler doesn't use such an approach, and is far more flexible and performant. Moreover, task.delay poses an issue with retaining the execution after the thread has been closed, or script has been destroyed. The Scheduler will continue to run even after the thread dies, or the script gets destroyed. Making it a great substitute for Debris.

As well as performance, the Scheduler can take in any kind of object Tome is able to take in. This allows you to schedule removal of threads, classes, functions and more.