Sync Dispatcher
Asynchronous sync dispatcher for DB-backed config caching.
This class manages a background thread that consumes a queue of SyncTasks, ensuring that config objects evicted from the in-memory cache are persisted to the database without blocking the main thread.
Typically used internally by DB-backed Yacla config loaders to provide write-behind caching and eventual consistency with minimal latency.
The dispatcher guarantees that all enqueued tasks are completed before shutdown.
Example usage:
val dispatcher = SyncDispatcher(myAccessLayer)
dispatcher.enqueue(SyncDispatcher.SyncTask("key", config, MyClass::class.java))
...
dispatcher.shutdownAndWait()Content copied to clipboard
Types
Functions
Link copied to clipboard
Enqueues a SyncTask for asynchronous saving to the database.
Link copied to clipboard
Waits until all currently enqueued and active tasks are completed, then stops the worker thread. Blocks the caller until completion.