diff options
author | Ayke van Laethem <[email protected]> | 2024-10-28 15:58:46 +0100 |
---|---|---|
committer | Ayke <[email protected]> | 2024-11-22 08:17:35 +0100 |
commit | f75187392d511ae37c857e2c10a3d59136fbab69 (patch) | |
tree | 2c230744bfd116d0506b58e55b8359b8459d4ca9 | |
parent | ecc6d16f223f78ace8c71850b1a2b5cfce8c324c (diff) | |
download | tinygo-f75187392d511ae37c857e2c10a3d59136fbab69.tar.gz tinygo-f75187392d511ae37c857e2c10a3d59136fbab69.zip |
internal/task: implement PMutex
PMutex is a mutex when threading is possible, and a dummy mutex-like
object (that doesn't do anything) otherwise.
-rw-r--r-- | src/internal/task/pmutex-cooperative.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/internal/task/pmutex-cooperative.go b/src/internal/task/pmutex-cooperative.go new file mode 100644 index 000000000..ae2aa4bad --- /dev/null +++ b/src/internal/task/pmutex-cooperative.go @@ -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() { +} |