Skip to content

Commit d97a7d0

Browse files
aykevldeadprogram
authored andcommitted
sd: don't block other goroutines while scanning
This is still a stopgap, but slightly better than what we had before. Note that `wfe` probably didn't save any battery power anyway since `wfe` doesn't work as expected when the SoftDevice is enabled.
1 parent a4c20a0 commit d97a7d0

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

gap_nrf528xx-central.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package bluetooth
55
import (
66
"device/arm"
77
"errors"
8+
"runtime"
89
"runtime/volatile"
910
"time"
1011
"unsafe"
@@ -58,8 +59,8 @@ func (a *Adapter) Scan(callback func(*Adapter, ScanResult)) error {
5859
for {
5960
// Wait for the next advertisement packet to arrive.
6061
// TODO: use some sort of condition variable once the scheduler supports
61-
// them.
62-
arm.Asm("wfe")
62+
// them. Using Gosched() here as a stopgap to let other goroutines run.
63+
runtime.Gosched()
6364
if gotScanReport.Get() == 0 {
6465
// Spurious event. Continue waiting.
6566
continue

0 commit comments

Comments
 (0)