summaryrefslogtreecommitdiffstats
path: root/server/duty.go
diff options
context:
space:
mode:
Diffstat (limited to 'server/duty.go')
-rw-r--r--server/duty.go11
1 files changed, 4 insertions, 7 deletions
diff --git a/server/duty.go b/server/duty.go
index ae32ecb..82bf60f 100644
--- a/server/duty.go
+++ b/server/duty.go
@@ -2,20 +2,19 @@ package main
import (
"fmt"
+ "github.com/sam-rba/share"
"log"
"net/http"
"strconv"
- "sync"
)
type DutyCycle float32
type DutyCycleHandler struct {
- mu sync.Mutex
- dc DutyCycle
+ dc share.Val[DutyCycle]
}
-func (h *DutyCycleHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
+func (h DutyCycleHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
log.Println(r.Method, r.URL)
if r.Method != http.MethodPost {
@@ -30,7 +29,5 @@ func (h *DutyCycleHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
return
}
- h.mu.Lock()
- defer h.mu.Unlock()
- h.dc = DutyCycle(dc)
+ h.dc.Set <- DutyCycle(dc)
}