Wideband autonomous SDR analysis engine forked from sdr-visual-suite
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

37 строки
1.0KB

  1. package main
  2. import (
  3. "time"
  4. "sdr-wideband-suite/internal/pipeline"
  5. )
  6. type arbitrator struct {
  7. refinementHold *pipeline.RefinementHold
  8. queues *decisionQueues
  9. }
  10. func newArbitrator() *arbitrator {
  11. return &arbitrator{
  12. refinementHold: &pipeline.RefinementHold{Active: map[int64]time.Time{}},
  13. queues: newDecisionQueues(),
  14. }
  15. }
  16. func (a *arbitrator) AdmitRefinement(plan pipeline.RefinementPlan, policy pipeline.Policy, now time.Time) pipeline.RefinementAdmissionResult {
  17. if a == nil {
  18. return pipeline.AdmitRefinementPlan(plan, policy, now, nil)
  19. }
  20. if a.refinementHold == nil {
  21. a.refinementHold = &pipeline.RefinementHold{Active: map[int64]time.Time{}}
  22. }
  23. return pipeline.AdmitRefinementPlan(plan, policy, now, a.refinementHold)
  24. }
  25. func (a *arbitrator) ApplyDecisions(decisions []pipeline.SignalDecision, budget pipeline.BudgetModel, now time.Time, policy pipeline.Policy) decisionQueueStats {
  26. if a == nil || a.queues == nil {
  27. return decisionQueueStats{}
  28. }
  29. return a.queues.Apply(decisions, budget, now, policy)
  30. }