public <T> Mono<T> schedule(Mono<T> mono) {
        mono = mono.doFinally(signalType -> {
            synchronized (this) {
                Sinks.One<?> sink = pendingTasks.poll();
                if (sink == null) {
                    hasRunningTask = false;
                } else {
                    sink.tryEmitEmpty();
                }
            }
        });
        synchronized (this) {
            if (!hasRunningTask) {
                hasRunningTask = true;
                return mono;
            }
            Sinks.One<T> sink = Sinks.one();
            pendingTasks.add(sink);
            return sink.asMono()
                    .then(mono);
        }
    }
The class is used to run tasks one by one.

@author James Chen
turms-server-common/src/main/java/im/turms/server/common/infra/reactor/TaskScheduler.java