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{}))
|
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)
|
// (we call it compiler to avoid confusion with dagger runtime)
|
||||||
// Use this instead of cue.Runtime
|
// Use this instead of cue.Runtime
|
||||||
type Compiler struct {
|
type Compiler struct {
|
||||||
sync.RWMutex
|
l sync.RWMutex
|
||||||
cue.Runtime
|
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 {
|
func (cc *Compiler) Cue() *cue.Runtime {
|
||||||
return &(cc.Runtime)
|
return &(cc.Runtime)
|
||||||
}
|
}
|
||||||
@ -24,8 +40,8 @@ func (cc *Compiler) EmptyStruct() (*Value, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (cc *Compiler) Compile(name string, src interface{}) (*Value, error) {
|
func (cc *Compiler) Compile(name string, src interface{}) (*Value, error) {
|
||||||
cc.Lock()
|
cc.lock()
|
||||||
defer cc.Unlock()
|
defer cc.unlock()
|
||||||
|
|
||||||
inst, err := cc.Cue().Compile(name, src)
|
inst, err := cc.Cue().Compile(name, src)
|
||||||
if err != nil {
|
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.
|
// Fill the value in-place, unlike Merge which returns a copy.
|
||||||
func (v *Value) Fill(x interface{}) error {
|
func (v *Value) Fill(x interface{}) error {
|
||||||
cc.Lock()
|
cc.lock()
|
||||||
defer cc.Unlock()
|
defer cc.unlock()
|
||||||
|
|
||||||
// If calling Fill() with a Value, we want to use the underlying
|
// If calling Fill() with a Value, we want to use the underlying
|
||||||
// cue.Value to fill.
|
// 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
|
// LookupPath is a concurrency safe wrapper around cue.Value.LookupPath
|
||||||
func (v *Value) LookupPath(p cue.Path) *Value {
|
func (v *Value) LookupPath(p cue.Path) *Value {
|
||||||
cc.RLock()
|
cc.rlock()
|
||||||
defer cc.RUnlock()
|
defer cc.runlock()
|
||||||
|
|
||||||
return v.Wrap(v.val.LookupPath(p))
|
return v.Wrap(v.val.LookupPath(p))
|
||||||
}
|
}
|
||||||
@ -147,9 +147,9 @@ func (v *Value) Merge(x interface{}, path ...string) (*Value, error) {
|
|||||||
x = xval.val
|
x = xval.val
|
||||||
}
|
}
|
||||||
|
|
||||||
cc.Lock()
|
cc.lock()
|
||||||
result := v.Wrap(v.val.Fill(x, path...))
|
result := v.Wrap(v.val.Fill(x, path...))
|
||||||
cc.Unlock()
|
cc.unlock()
|
||||||
|
|
||||||
return result, result.Validate()
|
return result, result.Validate()
|
||||||
}
|
}
|
||||||
@ -220,8 +220,8 @@ func (v *Value) Validate() error {
|
|||||||
|
|
||||||
// Return cue source for this value
|
// Return cue source for this value
|
||||||
func (v *Value) Source() ([]byte, error) {
|
func (v *Value) Source() ([]byte, error) {
|
||||||
cc.RLock()
|
cc.rlock()
|
||||||
defer cc.RUnlock()
|
defer cc.runlock()
|
||||||
|
|
||||||
return cueformat.Node(v.val.Eval().Syntax())
|
return cueformat.Node(v.val.Eval().Syntax())
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user