mirror of
https://github.com/MeshCore-Beacon/beacon-server.git
synced 2026-10-16 13:49:56 +00:00
Imported boundaries override borderFile on the border map and for foreign marking, falling back to the manual border when MeshMapper has none.
29 lines
781 B
Go
29 lines
781 B
Go
// Copyright 2026 Beacon Contributors
|
|
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
package borders
|
|
|
|
import "sync/atomic"
|
|
|
|
// Live lets boundary refreshes replace the classifier under concurrent readers.
|
|
// A nil Live disables classification; an empty one reports unknown until stored.
|
|
type Live struct{ current atomic.Pointer[Local] }
|
|
|
|
func NewLive(local *Local) *Live {
|
|
live := &Live{}
|
|
live.current.Store(local)
|
|
return live
|
|
}
|
|
|
|
func (l *Live) Store(local *Local) { l.current.Store(local) }
|
|
|
|
// Ready reports whether any boundary is loaded.
|
|
func (l *Live) Ready() bool { return l != nil && l.current.Load() != nil }
|
|
|
|
func (l *Live) PossiblyForeign(role int16, lat, lng *float64) *bool {
|
|
if l == nil {
|
|
return nil
|
|
}
|
|
return l.current.Load().PossiblyForeign(role, lat, lng)
|
|
}
|