-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstedy_mutability.go
More file actions
43 lines (36 loc) · 1.27 KB
/
Copy pathstedy_mutability.go
File metadata and controls
43 lines (36 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//go:build thread_unsafe_mutability
package stedy
// ParamMutator allows mutating engine parameters at runtime without recreating.
// *Stedy[L] implements this interface when built with -tags thread_unsafe_mutability.
// Without the build tag, the engine is immutable — recreate via New/NewDefault.
//
// Thread safety: ParamMutator methods are NOT thread-safe. Concurrent mutation
// and Ingest calls produce undefined behaviour. Use external synchronization
// (mutex, per-goroutine engine) when mutating across goroutines.
type ParamMutator interface {
SetAlpha(float32)
SetThetaMicro(float32)
SetThetaDelta(float32)
SetWeightMicro(float32)
SetWeightMacro(float32)
}
// SetAlpha updates alpha smoothing factor without recreating engine.
func (s *Stedy[L]) SetAlpha(a float32) {
s.alpha = a
}
// SetThetaMicro updates micro-inversion threshold.
func (s *Stedy[L]) SetThetaMicro(tm float32) {
s.thetaMicro = tm
}
// SetThetaDelta updates anomaly distance threshold.
func (s *Stedy[L]) SetThetaDelta(td float32) {
s.thetaDeltaSqr = td * td
}
// SetWeightMicro updates micro-inversion weight.
func (s *Stedy[L]) SetWeightMicro(wm float32) {
s.weightMicro = wm
}
// SetWeightMacro updates macro-inversion weight.
func (s *Stedy[L]) SetWeightMacro(wM float32) {
s.weightMacro = wM
}