Skip to content

Commit f751873

Browse files
committed
internal/task: implement PMutex
PMutex is a mutex when threading is possible, and a dummy mutex-like object (that doesn't do anything) otherwise.
1 parent ecc6d16 commit f751873

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package task
2+
3+
// PMutex is a real mutex on systems that can be either preemptive or threaded,
4+
// and a dummy lock on other (purely cooperative) systems.
5+
//
6+
// It is mainly useful for short operations that need a lock when threading may
7+
// be involved, but which do not need a lock with a purely cooperative
8+
// scheduler.
9+
type PMutex struct {
10+
}
11+
12+
func (m *PMutex) Lock() {
13+
}
14+
15+
func (m *PMutex) Unlock() {
16+
}

0 commit comments

Comments
 (0)