diff options
| author | Sam Anthony <sam@samanthony.xyz> | 2024-11-21 17:53:22 -0500 |
|---|---|---|
| committer | Sam Anthony <sam@samanthony.xyz> | 2024-11-21 17:53:22 -0500 |
| commit | 460093026a28744acf24cd176f83674d5ead63eb (patch) | |
| tree | a66c9406a0cd45176713305eb9d45d31e4c0b828 /server/duty.go | |
| parent | e9ebb8126224353c7090889c38e49415497a53cd (diff) | |
| download | soen422-460093026a28744acf24cd176f83674d5ead63eb.zip | |
server dashboard: display duty cycle
Diffstat (limited to 'server/duty.go')
| -rw-r--r-- | server/duty.go | 11 |
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) } |