Skip to content

Commit

Permalink
runtime: remove Cond
Browse files Browse the repository at this point in the history
I don't think this is used anywhere right now, and it would need to be
updated to work with multithreading. So instead of fixing it, I think we
can remove it.

My original intention was to have something like this that could be used
in the machine package, but since this is in the runtime package (and
the runtime package imports the machine package on baremetal) it can't
actually be used that way.

I checked the TinyGo repo and the drivers repo, and `runtime.Cond` isn't
used anywhere except in that one test.
  • Loading branch information
aykevl committed Dec 1, 2024
1 parent 3b80621 commit 6a30144
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 172 deletions.
90 changes: 0 additions & 90 deletions src/runtime/cond.go

This file was deleted.

38 changes: 0 additions & 38 deletions src/runtime/cond_nosched.go

This file was deleted.

44 changes: 0 additions & 44 deletions testdata/goroutines.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package main

import (
"runtime"
"sync"
"time"
)
Expand Down Expand Up @@ -83,8 +82,6 @@ func main() {

testGoOnInterface(Foo(0))

testCond()

testIssue1790()

done := make(chan int)
Expand Down Expand Up @@ -172,47 +169,6 @@ func testGoOnBuiltins() {
}
}

func testCond() {
var cond runtime.Cond
go func() {
// Wait for the caller to wait on the cond.
time.Sleep(time.Millisecond)

// Notify the caller.
ok := cond.Notify()
if !ok {
panic("notification not sent")
}

// This notification will be buffered inside the cond.
ok = cond.Notify()
if !ok {
panic("notification not queued")
}

// This notification should fail, since there is already one buffered.
ok = cond.Notify()
if ok {
panic("notification double-sent")
}
}()

// Verify that the cond has no pending notifications.
ok := cond.Poll()
if ok {
panic("unexpected early notification")
}

// Wait for the goroutine spawned earlier to send a notification.
cond.Wait()

// The goroutine should have also queued a notification in the cond.
ok = cond.Poll()
if !ok {
panic("missing queued notification")
}
}

var once sync.Once

func testGoOnInterface(f Itf) {
Expand Down

0 comments on commit 6a30144

Please sign in to comment.