//go:build moxie.unicore package task //go:linkname eventLoopTick runtime.eventLoopTick func eventLoopTick() type Mutex struct { locked bool depth int blocked Stack } func (m *Mutex) Lock() { // Single-threaded: allow reentrant locking (no contention possible). m.depth++ m.locked = true } func (m *Mutex) Unlock() { if !m.locked { panic("sync: unlock of unlocked Mutex") } m.depth-- if m.depth == 0 { m.locked = false } } // TryLock tries to lock m and reports whether it succeeded. // // Note that while correct uses of TryLock do exist, they are rare, // and use of TryLock is often a sign of a deeper problem // in a particular use of mutexes. func (m *Mutex) TryLock() bool { if m.locked { return false } m.Lock() return true }