mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-10 05:53:39 +00:00
all: use a custom sync package
The sync package is strongly tied to the runtime, so it's easier to implement a new one. Besides, it's pretty big so it's better to replace it.
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
package sync
|
||||
|
||||
type Once struct {
|
||||
done bool
|
||||
m Mutex
|
||||
}
|
||||
|
||||
func (o *Once) Do(f func()) {
|
||||
o.m.Lock()
|
||||
defer o.m.Unlock()
|
||||
if o.done {
|
||||
return
|
||||
}
|
||||
o.done = true
|
||||
f()
|
||||
}
|
||||
Reference in New Issue
Block a user