Wideband autonomous SDR analysis engine forked from sdr-visual-suite
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
889B

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