fix code after moving address/crypto/util

This commit is contained in:
Arceliar 2018-12-14 20:49:18 -06:00
parent 2c68d41409
commit ea4ca02681
18 changed files with 469 additions and 421 deletions

View file

@ -1,21 +1,21 @@
package yggdrasil
package util
// These are misc. utility functions that didn't really fit anywhere else
import "runtime"
// A wrapper around runtime.Gosched() so it doesn't need to be imported elsewhere.
func util_yield() {
func Yield() {
runtime.Gosched()
}
// A wrapper around runtime.LockOSThread() so it doesn't need to be imported elsewhere.
func util_lockthread() {
func LockThread() {
runtime.LockOSThread()
}
// A wrapper around runtime.UnlockOSThread() so it doesn't need to be imported elsewhere.
func util_unlockthread() {
func UnlockThread() {
runtime.UnlockOSThread()
}
@ -23,15 +23,12 @@ func util_unlockthread() {
// It's used like a sync.Pool, but with a fixed size and typechecked without type casts to/from interface{} (which were making the profiles look ugly).
var byteStore chan []byte
// Initializes the byteStore
func util_initByteStore() {
if byteStore == nil {
byteStore = make(chan []byte, 32)
}
func init() {
byteStore = make(chan []byte, 32)
}
// Gets an empty slice from the byte store, if one is available, or else returns a new nil slice.
func util_getBytes() []byte {
func GetBytes() []byte {
select {
case bs := <-byteStore:
return bs[:0]
@ -41,7 +38,7 @@ func util_getBytes() []byte {
}
// Puts a slice in the store, if there's room, or else returns and lets the slice get collected.
func util_putBytes(bs []byte) {
func PutBytes(bs []byte) {
select {
case byteStore <- bs:
default: