Compare commits

...

2 Commits

Author SHA1 Message Date
9a537bb8c2 v0.0.604
All checks were successful
Build Docker and Deploy / Run goext test-suite (push) Successful in 3m16s
2025-09-20 15:21:15 +02:00
78ad103151 v0.0.603
Some checks failed
Build Docker and Deploy / Run goext test-suite (push) Has been cancelled
2025-09-20 15:19:09 +02:00
2 changed files with 18 additions and 5 deletions

View File

@@ -9,6 +9,12 @@ import (
"git.blackforestbytes.com/BlackForestBytes/goext/syncext" "git.blackforestbytes.com/BlackForestBytes/goext/syncext"
) )
// DelayedCombiningInvoker is a utility to combine multiple consecutive requests into a single execution
//
// Requests are made with Request(), and consecutive requests are combined during the `delay` period.
//
// Can be used, e.g., for search-controls, where we want to init the search when teh user stops typing
// Or generally to queue an execution once a burst of requests is over.
type DelayedCombiningInvoker struct { type DelayedCombiningInvoker struct {
syncLock sync.Mutex syncLock sync.Mutex
triggerChan chan bool triggerChan chan bool
@@ -79,10 +85,14 @@ func (d *DelayedCombiningInvoker) Request() {
} }
func (d *DelayedCombiningInvoker) run() { func (d *DelayedCombiningInvoker) run() {
needsExecutorRunningCleanup := true
defer func() { defer func() {
d.syncLock.Lock() if needsExecutorRunningCleanup {
d.executorRunning.Set(false) d.syncLock.Lock()
d.syncLock.Unlock() d.executorRunning.Set(false)
d.syncLock.Unlock()
}
}() }()
for { for {
@@ -129,6 +139,9 @@ func (d *DelayedCombiningInvoker) run() {
_ = langext.RunPanicSafe(d.action) _ = langext.RunPanicSafe(d.action)
// ================================================= // =================================================
d.executorRunning.Set(false) // ensure HasPendingRequests returns fals ein onExecutionDone listener
needsExecutorRunningCleanup = false
for _, fn := range d.onExecutionDone { for _, fn := range d.onExecutionDone {
_ = langext.RunPanicSafe(fn) _ = langext.RunPanicSafe(fn)
} }

View File

@@ -1,5 +1,5 @@
package goext package goext
const GoextVersion = "0.0.602" const GoextVersion = "0.0.604"
const GoextVersionTimestamp = "2025-09-20T15:13:02+0200" const GoextVersionTimestamp = "2025-09-20T15:21:15+0200"