internal/pkg: cure entry/exit notification
Test / Create distribution (push) Successful in 55s
Test / Sandbox (push) Successful in 2m55s
Test / Hakurei (push) Successful in 4m49s
Test / Sandbox (race detector) (push) Successful in 6m7s
Test / Hakurei (race detector) (push) Successful in 7m42s
Test / ShareFS (push) Successful in 8m10s
Test / Flake checks (push) Successful in 1m39s
Test / Create distribution (push) Successful in 55s
Test / Sandbox (push) Successful in 2m55s
Test / Hakurei (push) Successful in 4m49s
Test / Sandbox (race detector) (push) Successful in 6m7s
Test / Hakurei (race detector) (push) Successful in 7m42s
Test / ShareFS (push) Successful in 8m10s
Test / Flake checks (push) Successful in 1m39s
This enables cure status display without inspecting internal state. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
@@ -1826,6 +1826,10 @@ func (e *DependencyCureError) Error() string {
|
||||
|
||||
// enterCure must be called before entering an [Artifact] implementation.
|
||||
func (c *Cache) enterCure(a Artifact, curesExempt bool) error {
|
||||
if c.attr.Notify != nil {
|
||||
c.attr.Notify <- true
|
||||
}
|
||||
|
||||
if a.IsExclusive() {
|
||||
c.exclMu.Lock()
|
||||
}
|
||||
@@ -1848,6 +1852,10 @@ func (c *Cache) enterCure(a Artifact, curesExempt bool) error {
|
||||
|
||||
// exitCure must be called after exiting an [Artifact] implementation.
|
||||
func (c *Cache) exitCure(a Artifact, curesExempt bool) {
|
||||
if c.attr.Notify != nil {
|
||||
c.attr.Notify <- false
|
||||
}
|
||||
|
||||
if a.IsExclusive() {
|
||||
c.exclMu.Unlock()
|
||||
}
|
||||
@@ -2741,6 +2749,10 @@ func (c *Cache) Close() {
|
||||
c.wg.Wait()
|
||||
close(c.cures)
|
||||
c.unlock()
|
||||
|
||||
if c.attr.Notify != nil {
|
||||
close(c.attr.Notify)
|
||||
}
|
||||
}
|
||||
|
||||
// UnsupportedVariantError describes an on-disk cache with an extension variant
|
||||
@@ -2768,6 +2780,8 @@ type CacheAttr struct {
|
||||
Jobs int
|
||||
// Preferred loadavg target, when applicable.
|
||||
Load int
|
||||
// Optional cure entry and exit notification.
|
||||
Notify chan<- bool
|
||||
|
||||
// Omit the [lockedfile] lock.
|
||||
skipLock bool
|
||||
|
||||
Reference in New Issue
Block a user