mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-08 13:03:39 +00:00
extend stdlib to allow import of more packages (#1099)
* stdlib: extend stdlib to allow import of more packages
This commit is contained in:
@@ -42,3 +42,18 @@ func (m *Map) Store(key, value interface{}) {
|
||||
}
|
||||
m.m[key] = value
|
||||
}
|
||||
|
||||
func (m *Map) Range(f func(key, value interface{}) bool) {
|
||||
m.lock.Lock()
|
||||
defer m.lock.Unlock()
|
||||
|
||||
if m.m == nil {
|
||||
return
|
||||
}
|
||||
|
||||
for k, v := range m.m {
|
||||
if !f(k, v) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,3 +74,14 @@ type Locker interface {
|
||||
Lock()
|
||||
Unlock()
|
||||
}
|
||||
|
||||
// RLocker returns a Locker interface that implements
|
||||
// the Lock and Unlock methods by calling rw.RLock and rw.RUnlock.
|
||||
func (rw *RWMutex) RLocker() Locker {
|
||||
return (*rlocker)(rw)
|
||||
}
|
||||
|
||||
type rlocker RWMutex
|
||||
|
||||
func (r *rlocker) Lock() { (*RWMutex)(r).RLock() }
|
||||
func (r *rlocker) Unlock() { (*RWMutex)(r).RUnlock() }
|
||||
|
||||
Reference in New Issue
Block a user