diff --git a/src/main/kotlin/ru/dbotthepony/kommons/util/MailboxExecutorService.kt b/src/main/kotlin/ru/dbotthepony/kommons/util/MailboxExecutorService.kt index b5c8aa3..c13b5e6 100644 --- a/src/main/kotlin/ru/dbotthepony/kommons/util/MailboxExecutorService.kt +++ b/src/main/kotlin/ru/dbotthepony/kommons/util/MailboxExecutorService.kt @@ -36,6 +36,12 @@ private fun > LinkedList.enqueue(value: E) { } } +/** + * [ScheduledExecutorService] which act as a mailbox, [executeQueuedTasks] must be called from main thread. + * + * [submit], [execute], etc can be called on any thread. If any of enqueueing methods are called on the same thread + * as where [executeQueuedTasks] was called, executes provided lambda immediately and returns completed future. + */ class MailboxExecutorService(thread: Thread = Thread.currentThread()) : ScheduledExecutorService { @Volatile var thread: Thread = thread