Skip to content

Commit

Permalink
Fix high CPU consumption on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
silvanocerza committed Dec 3, 2021
1 parent a7e7132 commit fd5a4ff
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion sync/sync_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"fmt"
"runtime"
"syscall"
"time"
"unsafe"

discovery "github.com/arduino/pluggable-discovery-protocol-handler/v2"
Expand Down Expand Up @@ -131,7 +132,8 @@ func Start(eventCB discovery.EventCallback, errorCB discovery.ErrorCallback) (ch
if !ev {
return
}
default:
case <-time.After(time.Millisecond * 500):
// Use a small timeout instead of default case to avoid high CPU consumption
}
updates, err := enumerator.GetDetailedPortsList()
if err != nil {
Expand Down

0 comments on commit fd5a4ff

Please sign in to comment.