Skip to content

Commit

Permalink
internal/task: implement PMutex
Browse files Browse the repository at this point in the history
PMutex is a mutex when threading is possible, and a dummy mutex-like
object (that doesn't do anything) otherwise.
  • Loading branch information
aykevl committed Nov 21, 2024
1 parent dd1ebbd commit 30831d3
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/internal/task/pmutex-cooperative.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package task

// PMutex is a real mutex on systems that can be either preemptive or threaded,
// and a dummy lock on other (purely cooperative) systems.
//
// It is mainly useful for short operations that need a lock when threading may
// be involved, but which do not need a lock with a purely cooperative
// scheduler.
type PMutex struct {
}

func (m *PMutex) Lock() {
}

func (m *PMutex) Unlock() {
}

0 comments on commit 30831d3

Please sign in to comment.