Skip to content

Instantly share code, notes, and snippets.

@SanderSmee
SanderSmee / CoroutineDebouncer.kt
Created February 15, 2023 14:46 — forked from maxpert/CoroutineDebouncer.kt
Kotlin Coroutine Debouncer
class CoroutineDebouncer<K, V> constructor(
private val pendingBoard: ConcurrentMap<K, Deferred<V?>>
) {
/**
* Debounce given a `task` based upon given `id`. This prevents jobs with same IDs run in parallel.
* For subsequent callers get Deferred<V> of first (winning) coroutine.
* Once Deferred<V> completes it is remove from the board.
*
* @param id for uniquely identifying a task
* @param context under which given coroutine will be executed
@Startup
@ApplicationScoped
public class SingletonFeatureManagerProvider {
@ConfigProperty(name = "my.toggles.config.file")
String featuresPropertyFileLocation;
FeatureManager featureManager;
@PostConstruct
public void init() {
package ari.dnrs.registry.configuration;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
import java.util.Set;
import org.junit.Before;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
/*
* Template backbone.js code that encapsulates a
* datatable.net table within a view for a hypothetical ;)
* auction listings application.
*/
var HomeRouter = Backbone.Router.extend({
routes: {
'refresh' : 'refresh',