dagger/cc: remove locking methods from public API
Signed-off-by: Solomon Hykes <sh.github.6811@hykes.org>
This commit is contained in:
parent
2019d29c08
commit
be8f600c59
@ -35,19 +35,3 @@ func Err(err error) error {
|
||||
}
|
||||
return errors.New(cueerrors.Details(err, &cueerrors.Config{}))
|
||||
}
|
||||
|
||||
func Lock() {
|
||||
cc.Lock()
|
||||
}
|
||||
|
||||
func Unlock() {
|
||||
cc.Unlock()
|
||||
}
|
||||
|
||||
func RLock() {
|
||||
cc.RLock()
|
||||
}
|
||||
|
||||
func RUnlock() {
|
||||
cc.RUnlock()
|
||||
}
|
||||
|
@ -10,10 +10,26 @@ import (
|
||||
// (we call it compiler to avoid confusion with dagger runtime)
|
||||
// Use this instead of cue.Runtime
|
||||
type Compiler struct {
|
||||
sync.RWMutex
|
||||
l sync.RWMutex
|
||||
cue.Runtime
|
||||
}
|
||||
|
||||
func (cc *Compiler) lock() {
|
||||
cc.l.Lock()
|
||||
}
|
||||
|
||||
func (cc *Compiler) unlock() {
|
||||
cc.l.Unlock()
|
||||
}
|
||||
|
||||
func (cc *Compiler) rlock() {
|
||||
cc.l.RLock()
|
||||
}
|
||||
|
||||
func (cc *Compiler) runlock() {
|
||||
cc.l.RUnlock()
|
||||
}
|
||||
|
||||
func (cc *Compiler) Cue() *cue.Runtime {
|
||||
return &(cc.Runtime)
|
||||
}
|
||||
@ -24,8 +40,8 @@ func (cc *Compiler) EmptyStruct() (*Value, error) {
|
||||
}
|
||||
|
||||
func (cc *Compiler) Compile(name string, src interface{}) (*Value, error) {
|
||||
cc.Lock()
|
||||
defer cc.Unlock()
|
||||
cc.lock()
|
||||
defer cc.unlock()
|
||||
|
||||
inst, err := cc.Cue().Compile(name, src)
|
||||
if err != nil {
|
||||
|
@ -29,8 +29,8 @@ func wrapValue(v cue.Value, inst *cue.Instance) *Value {
|
||||
|
||||
// Fill the value in-place, unlike Merge which returns a copy.
|
||||
func (v *Value) Fill(x interface{}) error {
|
||||
cc.Lock()
|
||||
defer cc.Unlock()
|
||||
cc.lock()
|
||||
defer cc.unlock()
|
||||
|
||||
// If calling Fill() with a Value, we want to use the underlying
|
||||
// cue.Value to fill.
|
||||
@ -44,8 +44,8 @@ func (v *Value) Fill(x interface{}) error {
|
||||
|
||||
// LookupPath is a concurrency safe wrapper around cue.Value.LookupPath
|
||||
func (v *Value) LookupPath(p cue.Path) *Value {
|
||||
cc.RLock()
|
||||
defer cc.RUnlock()
|
||||
cc.rlock()
|
||||
defer cc.runlock()
|
||||
|
||||
return v.Wrap(v.val.LookupPath(p))
|
||||
}
|
||||
@ -147,9 +147,9 @@ func (v *Value) Merge(x interface{}, path ...string) (*Value, error) {
|
||||
x = xval.val
|
||||
}
|
||||
|
||||
cc.Lock()
|
||||
cc.lock()
|
||||
result := v.Wrap(v.val.Fill(x, path...))
|
||||
cc.Unlock()
|
||||
cc.unlock()
|
||||
|
||||
return result, result.Validate()
|
||||
}
|
||||
@ -220,8 +220,8 @@ func (v *Value) Validate() error {
|
||||
|
||||
// Return cue source for this value
|
||||
func (v *Value) Source() ([]byte, error) {
|
||||
cc.RLock()
|
||||
defer cc.RUnlock()
|
||||
cc.rlock()
|
||||
defer cc.runlock()
|
||||
|
||||
return cueformat.Node(v.val.Eval().Syntax())
|
||||
}
|
||||
|
Reference in New Issue
Block a user