Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type SyncedQ ¶
func NewSyncedQ ¶
func NewSyncedQ() *SyncedQ
type ThrottledTrigger ¶ added in v1.3.13
type ThrottledTrigger struct {
// contains filtered or unexported fields
}
ThrottledTrigger calls a function after a period of inactivity (idle), or unconditionally once the max duration is reached — whichever comes first. Typical use: coalescing rapid updates (e.g. terminal redraws) into a single call, avoiding intermediate frames.
func NewThrottledTrigger ¶ added in v1.3.13
func NewThrottledTrigger(fn func(), idle, max time.Duration) *ThrottledTrigger
NewThrottledTrigger creates a ThrottledTrigger that calls fn when triggered. idle: how long to wait after the last Trigger() call before firing.
Each new Trigger() resets this window. Use a small value (e.g. 2ms) to coalesce bursts of updates into a single paint.
max: the maximum time to wait before firing, even if Trigger() keeps
being called continuously. Prevents starvation during sustained output (e.g. cat largefile). Use ~16ms for ~60fps.
func (*ThrottledTrigger) Trigger ¶ added in v1.3.13
func (t *ThrottledTrigger) Trigger()
Trigger marca como dirty e arma os timers.
type Throttler ¶ added in v1.3.13
type Throttler struct {
sync.Mutex
Interval time.Duration
Fn func(done func())
// contains filtered or unexported fields
}
runs fn only one at a time without overlaps, and always runs one last time.
func NewThrottler ¶ added in v1.3.13
func NewThrottler() *Throttler
type WaitForSet ¶
type WaitForSet struct {
// contains filtered or unexported fields
}
Continously usable, instantiated once for many wait()/set() calls. Fails if wait() is not ready when set() is called. Usage:
w:=NewWaitForSet()
w.Start(5*time.Second)
...
// sync/async call to w.Set()
...
v,err := w.WaitForSet()
if err!=nil {
}
func NewWaitForSet ¶
func NewWaitForSet() *WaitForSet
func (*WaitForSet) Cancel ¶
func (w *WaitForSet) Cancel()
In case waitforset() is not going to be called.
func (*WaitForSet) Set ¶
func (w *WaitForSet) Set(v any) error
Fails if not able to set while get() is ready.
func (*WaitForSet) Start ¶
func (w *WaitForSet) Start(timeout time.Duration)
func (*WaitForSet) WaitForSet ¶
func (w *WaitForSet) WaitForSet() (any, error)