asSequentialScheduler

Transforms the current scheduler into a sequential one.

If the current scheduler already guarantees sequential execution, it is returned as is. Otherwise, a new sequential scheduler is created that wraps the original scheduler.

The returned sequential scheduler attempts to keep the original execution order until concurrent execution is detected. When concurrency is detected (i.e. when a new task is scheduled while a previous one hasn't finished yet), it stops preserving the original order and queues tasks internally to ensure sequential execution.

Return

a scheduler that guarantees sequential execution.