solver: small cleanup on function order

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
docker-18.09
Tonis Tiigi 2018-05-09 14:03:31 -07:00
parent e58870889f
commit 238e15b29e
1 changed files with 19 additions and 16 deletions

View File

@ -74,13 +74,14 @@ type dep struct {
keyMap map[string]*CacheKey
desiredState edgeStatusType
e *edge
slowCacheReq pipe.Receiver // TODO: reuse req
slowCacheReq pipe.Receiver
slowCacheComplete bool
slowCacheFoundKey bool
slowCacheKey *ExportableCacheKey
err error
}
// expDep holds secorndary exporter info for dependency
type expDep struct {
index int
cacheKey CacheKeyWithSelector
@ -90,12 +91,14 @@ func newDep(i Index) *dep {
return &dep{index: i, keyMap: map[string]*CacheKey{}}
}
// edgePipe is a pipe for requests between two edges
type edgePipe struct {
*pipe.Pipe
From, Target *edge
mu sync.Mutex
}
// edgeState hold basic mutable state info for an edge
type edgeState struct {
state edgeStatusType
result *SharedCachedResult
@ -103,13 +106,6 @@ type edgeState struct {
keys []ExportableCacheKey
}
func isEqualState(s1, s2 edgeState) bool {
if s1.state != s2.state || s1.result != s2.result || s1.cacheMap != s2.cacheMap || len(s1.keys) != len(s2.keys) {
return false
}
return true
}
type edgeRequest struct {
desiredState edgeStatusType
currentState edgeState
@ -342,14 +338,6 @@ func (e *edge) unpark(incoming []pipe.Sender, updates, allPipes []pipe.Receiver,
}
func withSelector(keys []ExportableCacheKey, selector digest.Digest) []CacheKeyWithSelector {
out := make([]CacheKeyWithSelector, len(keys))
for i, k := range keys {
out[i] = CacheKeyWithSelector{Selector: selector, CacheKey: k}
}
return out
}
func (e *edge) makeExportable(k *CacheKey, records []*CacheRecord) ExportableCacheKey {
return ExportableCacheKey{
CacheKey: k,
@ -857,3 +845,18 @@ func toResultSlice(cres []CachedResult) (out []Result) {
}
return out
}
func isEqualState(s1, s2 edgeState) bool {
if s1.state != s2.state || s1.result != s2.result || s1.cacheMap != s2.cacheMap || len(s1.keys) != len(s2.keys) {
return false
}
return true
}
func withSelector(keys []ExportableCacheKey, selector digest.Digest) []CacheKeyWithSelector {
out := make([]CacheKeyWithSelector, len(keys))
for i, k := range keys {
out[i] = CacheKeyWithSelector{Selector: selector, CacheKey: k}
}
return out
}