Merge pull request #13476 from containers/dependabot/go_modules/github.com/vbauerster/mpb/v7-7.4.1

Bump github.com/vbauerster/mpb/v7 from 7.3.2 to 7.4.1
This commit is contained in:
OpenShift Merge Robot
2022-03-10 09:02:06 -05:00
committed by GitHub
32 changed files with 519 additions and 323 deletions

4
go.mod
View File

@ -61,12 +61,12 @@ require (
github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635 github.com/syndtr/gocapability v0.0.0-20200815063812-42c35b437635
github.com/uber/jaeger-client-go v2.30.0+incompatible github.com/uber/jaeger-client-go v2.30.0+incompatible
github.com/ulikunitz/xz v0.5.10 github.com/ulikunitz/xz v0.5.10
github.com/vbauerster/mpb/v7 v7.3.2 github.com/vbauerster/mpb/v7 v7.4.1
github.com/vishvananda/netlink v1.1.1-0.20220115184804-dd687eb2f2d4 github.com/vishvananda/netlink v1.1.1-0.20220115184804-dd687eb2f2d4
go.etcd.io/bbolt v1.3.6 go.etcd.io/bbolt v1.3.6
golang.org/x/crypto v0.0.0-20220112180741-5e0467b6c7ce golang.org/x/crypto v0.0.0-20220112180741-5e0467b6c7ce
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27 golang.org/x/sys v0.0.0-20220209214540-3681064d5158
golang.org/x/text v0.3.7 golang.org/x/text v0.3.7
google.golang.org/protobuf v1.27.1 google.golang.org/protobuf v1.27.1
gopkg.in/yaml.v2 v2.4.0 gopkg.in/yaml.v2 v2.4.0

6
go.sum
View File

@ -1347,8 +1347,9 @@ github.com/valyala/quicktemplate v1.7.0/go.mod h1:sqKJnoaOF88V07vkO+9FL8fb9uZg/V
github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc= github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc=
github.com/vbatts/tar-split v0.11.2 h1:Via6XqJr0hceW4wff3QRzD5gAk/tatMw/4ZA7cTlIME= github.com/vbatts/tar-split v0.11.2 h1:Via6XqJr0hceW4wff3QRzD5gAk/tatMw/4ZA7cTlIME=
github.com/vbatts/tar-split v0.11.2/go.mod h1:vV3ZuO2yWSVsz+pfFzDG/upWH1JhjOiEaWq6kXyQ3VI= github.com/vbatts/tar-split v0.11.2/go.mod h1:vV3ZuO2yWSVsz+pfFzDG/upWH1JhjOiEaWq6kXyQ3VI=
github.com/vbauerster/mpb/v7 v7.3.2 h1:tCuxMy8G9cLdjb61b6wO7I1vRT/LyMEzRbr3xCC0JPU=
github.com/vbauerster/mpb/v7 v7.3.2/go.mod h1:wfxIZcOJq/bG1/lAtfzMXcOiSvbqVi/5GX5WCSi+IsA= github.com/vbauerster/mpb/v7 v7.3.2/go.mod h1:wfxIZcOJq/bG1/lAtfzMXcOiSvbqVi/5GX5WCSi+IsA=
github.com/vbauerster/mpb/v7 v7.4.1 h1:NhLMWQ3gNg2KJR8oeA9lO8Xvq+eNPmixDmB6JEQOUdA=
github.com/vbauerster/mpb/v7 v7.4.1/go.mod h1:Ygg2mV9Vj9sQBWqsK2m2pidcf9H3s6bNKtqd3/M4gBo=
github.com/viki-org/dnscache v0.0.0-20130720023526-c70c1f23c5d8/go.mod h1:dniwbG03GafCjFohMDmz6Zc6oCuiqgH6tGNyXTkHzXE= github.com/viki-org/dnscache v0.0.0-20130720023526-c70c1f23c5d8/go.mod h1:dniwbG03GafCjFohMDmz6Zc6oCuiqgH6tGNyXTkHzXE=
github.com/vishvananda/netlink v0.0.0-20181108222139-023a6dafdcdf/go.mod h1:+SR5DhBJrl6ZM7CoCKvpw5BKroDKQ+PJqOg65H/2ktk= github.com/vishvananda/netlink v0.0.0-20181108222139-023a6dafdcdf/go.mod h1:+SR5DhBJrl6ZM7CoCKvpw5BKroDKQ+PJqOg65H/2ktk=
github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE= github.com/vishvananda/netlink v1.1.0/go.mod h1:cTgwzPIzzgDAYoQrMm0EdrjRUBkTqKYppBueQtXaqoE=
@ -1754,8 +1755,9 @@ golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20211205182925-97ca703d548d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211205182925-97ca703d548d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27 h1:XDXtA5hveEEV8JB2l7nhMTp3t3cHp9ZpwcdjqyEWLlo=
golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220209214540-3681064d5158 h1:rm+CHSpPEEW2IsXUib1ThaHIjuBVZjxNgSKmBLFfD4c=
golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=

View File

@ -17,31 +17,21 @@ import (
// Bar represents a progress bar. // Bar represents a progress bar.
type Bar struct { type Bar struct {
priority int // used by heap index int // used by heap
index int // used by heap priority int // used by heap
hasEwma bool
toShutdown bool frameCh chan *renderFrame
toDrop bool operateState chan func(*bState)
noPop bool done chan struct{}
hasEwmaDecorators bool
operateState chan func(*bState)
frameCh chan *frame
// cancel is called either by user or on complete event
cancel func()
// done is closed after cacheState is assigned
done chan struct{}
// cacheState is populated, right after close(b.done)
cacheState *bState
container *Progress container *Progress
bs *bState
cancel func()
recoveredPanic interface{} recoveredPanic interface{}
} }
type extenderFunc func(in io.Reader, reqWidth int, st decor.Statistics) (out io.Reader, lines int) type extenderFunc func(in io.Reader, reqWidth int, st decor.Statistics) (out io.Reader, lines int)
// bState is actual bar state. It gets passed to *Bar.serve(...) monitor // bState is actual bar's state.
// goroutine.
type bState struct { type bState struct {
id int id int
priority int priority int
@ -52,7 +42,6 @@ type bState struct {
lastIncrement int64 lastIncrement int64
trimSpace bool trimSpace bool
completed bool completed bool
completeFlushed bool
aborted bool aborted bool
triggerComplete bool triggerComplete bool
dropOnComplete bool dropOnComplete bool
@ -66,29 +55,28 @@ type bState struct {
filler BarFiller filler BarFiller
middleware func(BarFiller) BarFiller middleware func(BarFiller) BarFiller
extender extenderFunc extender extenderFunc
debugOut io.Writer
// runningBar is a key for *pState.parkedBars afterBar *Bar // key for (*pState).queueBars
runningBar *Bar sync bool
debugOut io.Writer
} }
type frame struct { type renderFrame struct {
reader io.Reader reader io.Reader
lines int lines int
shutdown bool
} }
func newBar(container *Progress, bs *bState) *Bar { func newBar(container *Progress, bs *bState) *Bar {
ctx, cancel := context.WithCancel(container.ctx) ctx, cancel := context.WithCancel(container.ctx)
bar := &Bar{ bar := &Bar{
container: container,
priority: bs.priority, priority: bs.priority,
toDrop: bs.dropOnComplete, hasEwma: len(bs.ewmaDecorators) != 0,
noPop: bs.noPop, frameCh: make(chan *renderFrame, 1),
operateState: make(chan func(*bState)), operateState: make(chan func(*bState)),
frameCh: make(chan *frame, 1),
done: make(chan struct{}), done: make(chan struct{}),
container: container,
cancel: cancel, cancel: cancel,
} }
@ -97,12 +85,20 @@ func newBar(container *Progress, bs *bState) *Bar {
} }
// ProxyReader wraps r with metrics required for progress tracking. // ProxyReader wraps r with metrics required for progress tracking.
// Panics if r is nil. // If r is 'unknown total/size' reader it's mandatory to call
// (*Bar).SetTotal(-1, true) method after (Reader).Read returns io.EOF.
// Panics if r is nil. If bar is already completed or aborted, returns
// nil.
func (b *Bar) ProxyReader(r io.Reader) io.ReadCloser { func (b *Bar) ProxyReader(r io.Reader) io.ReadCloser {
if r == nil { if r == nil {
panic("expected non nil io.Reader") panic("expected non nil io.Reader")
} }
return b.newProxyReader(r) select {
case <-b.done:
return nil
default:
return b.newProxyReader(r)
}
} }
// ID returs id of the bar. // ID returs id of the bar.
@ -112,18 +108,18 @@ func (b *Bar) ID() int {
case b.operateState <- func(s *bState) { result <- s.id }: case b.operateState <- func(s *bState) { result <- s.id }:
return <-result return <-result
case <-b.done: case <-b.done:
return b.cacheState.id return b.bs.id
} }
} }
// Current returns bar's current number, in other words sum of all increments. // Current returns bar's current value, in other words sum of all increments.
func (b *Bar) Current() int64 { func (b *Bar) Current() int64 {
result := make(chan int64) result := make(chan int64)
select { select {
case b.operateState <- func(s *bState) { result <- s.current }: case b.operateState <- func(s *bState) { result <- s.current }:
return <-result return <-result
case <-b.done: case <-b.done:
return b.cacheState.current return b.bs.current
} }
} }
@ -142,7 +138,7 @@ func (b *Bar) SetRefill(amount int64) {
// TraverseDecorators traverses all available decorators and calls cb func on each. // TraverseDecorators traverses all available decorators and calls cb func on each.
func (b *Bar) TraverseDecorators(cb func(decor.Decorator)) { func (b *Bar) TraverseDecorators(cb func(decor.Decorator)) {
done := make(chan struct{}) sync := make(chan struct{})
select { select {
case b.operateState <- func(s *bState) { case b.operateState <- func(s *bState) {
for _, decorators := range [...][]decor.Decorator{ for _, decorators := range [...][]decor.Decorator{
@ -153,28 +149,56 @@ func (b *Bar) TraverseDecorators(cb func(decor.Decorator)) {
cb(extractBaseDecorator(d)) cb(extractBaseDecorator(d))
} }
} }
close(done) close(sync)
}: }:
<-done <-sync
case <-b.done: case <-b.done:
} }
} }
// SetTotal sets total dynamically. // EnableTriggerComplete enables triggering complete event. It's
// If total is negative it takes progress' current value. // effective only for bar which was constructed with `total <= 0` and
func (b *Bar) SetTotal(total int64, triggerComplete bool) { // after total has been set with (*Bar).SetTotal(int64, false). If bar
// has been incremented to the total, complete event is triggered right
// away.
func (b *Bar) EnableTriggerComplete() {
select { select {
case b.operateState <- func(s *bState) { case b.operateState <- func(s *bState) {
s.triggerComplete = triggerComplete if s.triggerComplete || s.total <= 0 {
return
}
if s.current >= s.total {
s.current = s.total
s.completed = true
go b.forceRefresh()
} else {
s.triggerComplete = true
}
}:
case <-b.done:
}
}
// SetTotal sets total to an arbitrary value. It's effective only for
// bar which was constructed with `total <= 0`. Setting total to negative
// value is equivalent to (*Bar).SetTotal((*Bar).Current(), bool).
// If triggerCompleteNow is true, total value is set to current and
// complete event is triggered right away.
func (b *Bar) SetTotal(total int64, triggerCompleteNow bool) {
select {
case b.operateState <- func(s *bState) {
if s.triggerComplete {
return
}
if total < 0 { if total < 0 {
s.total = s.current s.total = s.current
} else { } else {
s.total = total s.total = total
} }
if s.triggerComplete && !s.completed { if triggerCompleteNow {
s.current = s.total s.current = s.total
s.completed = true s.completed = true
go b.forceRefreshIfLastUncompleted() go b.forceRefresh()
} }
}: }:
case <-b.done: case <-b.done:
@ -191,7 +215,7 @@ func (b *Bar) SetCurrent(current int64) {
if s.triggerComplete && s.current >= s.total { if s.triggerComplete && s.current >= s.total {
s.current = s.total s.current = s.total
s.completed = true s.completed = true
go b.forceRefreshIfLastUncompleted() go b.forceRefresh()
} }
}: }:
case <-b.done: case <-b.done:
@ -220,7 +244,7 @@ func (b *Bar) IncrInt64(n int64) {
if s.triggerComplete && s.current >= s.total { if s.triggerComplete && s.current >= s.total {
s.current = s.total s.current = s.total
s.completed = true s.completed = true
go b.forceRefreshIfLastUncompleted() go b.forceRefresh()
} }
}: }:
case <-b.done: case <-b.done:
@ -242,9 +266,9 @@ func (b *Bar) DecoratorEwmaUpdate(dur time.Duration) {
} }
}: }:
case <-b.done: case <-b.done:
if b.cacheState.lastIncrement > 0 { if b.bs.lastIncrement > 0 {
b.cacheState.decoratorEwmaUpdate(dur) b.bs.decoratorEwmaUpdate(dur)
b.cacheState.lastIncrement = 0 b.bs.lastIncrement = 0
} }
} }
} }
@ -270,44 +294,33 @@ func (b *Bar) SetPriority(priority int) {
// Abort interrupts bar's running goroutine. Abort won't be engaged // Abort interrupts bar's running goroutine. Abort won't be engaged
// if bar is already in complete state. If drop is true bar will be // if bar is already in complete state. If drop is true bar will be
// removed as well. // removed as well. To make sure that bar has been removed call
// (*Bar).Wait method.
func (b *Bar) Abort(drop bool) { func (b *Bar) Abort(drop bool) {
done := make(chan struct{})
select { select {
case b.operateState <- func(s *bState) { case b.operateState <- func(s *bState) {
if s.completed { if s.completed || s.aborted {
close(done)
return return
} }
s.aborted = true s.aborted = true
b.cancel() s.dropOnComplete = drop
// container must be run during lifetime of this inner goroutine go b.forceRefresh()
// we control this by done channel declared above
go func() {
if drop {
b.container.dropBar(b)
} else {
var uncompleted int
b.container.traverseBars(func(bar *Bar) bool {
if b != bar && !bar.Completed() {
uncompleted++
return false
}
return true
})
if uncompleted == 0 {
b.container.refreshCh <- time.Now()
}
}
close(done) // release hold of Abort
}()
}: }:
// guarantee: container is alive during lifetime of this hold
<-done
case <-b.done: case <-b.done:
} }
} }
// Aborted reports whether the bar is in aborted state.
func (b *Bar) Aborted() bool {
result := make(chan bool)
select {
case b.operateState <- func(s *bState) { result <- s.aborted }:
return <-result
case <-b.done:
return b.bs.aborted
}
}
// Completed reports whether the bar is in completed state. // Completed reports whether the bar is in completed state.
func (b *Bar) Completed() bool { func (b *Bar) Completed() bool {
result := make(chan bool) result := make(chan bool)
@ -315,19 +328,28 @@ func (b *Bar) Completed() bool {
case b.operateState <- func(s *bState) { result <- s.completed }: case b.operateState <- func(s *bState) { result <- s.completed }:
return <-result return <-result
case <-b.done: case <-b.done:
return true return b.bs.completed
} }
} }
func (b *Bar) serve(ctx context.Context, s *bState) { // Wait blocks until bar is completed or aborted.
func (b *Bar) Wait() {
<-b.done
}
func (b *Bar) serve(ctx context.Context, bs *bState) {
defer b.container.bwg.Done() defer b.container.bwg.Done()
if bs.afterBar != nil && bs.sync {
bs.afterBar.Wait()
}
for { for {
select { select {
case op := <-b.operateState: case op := <-b.operateState:
op(s) op(bs)
case <-ctx.Done(): case <-ctx.Done():
s.decoratorShutdownNotify() bs.aborted = !bs.completed
b.cacheState = s bs.decoratorShutdownNotify()
b.bs = bs
close(b.done) close(b.done)
return return
} }
@ -337,79 +359,62 @@ func (b *Bar) serve(ctx context.Context, s *bState) {
func (b *Bar) render(tw int) { func (b *Bar) render(tw int) {
select { select {
case b.operateState <- func(s *bState) { case b.operateState <- func(s *bState) {
var reader io.Reader
var lines int
stat := newStatistics(tw, s) stat := newStatistics(tw, s)
defer func() { defer func() {
// recovering if user defined decorator panics for example // recovering if user defined decorator panics for example
if p := recover(); p != nil { if p := recover(); p != nil {
if b.recoveredPanic == nil { if s.debugOut != nil {
if s.debugOut != nil { fmt.Fprintln(s.debugOut, p)
fmt.Fprintln(s.debugOut, p) _, _ = s.debugOut.Write(debug.Stack())
_, _ = s.debugOut.Write(debug.Stack())
}
s.extender = makePanicExtender(p)
b.toShutdown = !b.toShutdown
b.recoveredPanic = p
} }
reader, lines := s.extender(nil, s.reqWidth, stat) s.aborted = !s.completed
b.frameCh <- &frame{reader, lines + 1} s.extender = makePanicExtender(p)
reader, lines = s.extender(nil, s.reqWidth, stat)
b.recoveredPanic = p
} }
s.completeFlushed = s.completed frame := renderFrame{
reader: reader,
lines: lines + 1,
shutdown: s.completed || s.aborted,
}
if frame.shutdown {
b.cancel()
}
b.frameCh <- &frame
}() }()
reader, lines := s.extender(s.draw(stat), s.reqWidth, stat)
b.toShutdown = s.completed && !s.completeFlushed
b.frameCh <- &frame{reader, lines + 1}
}:
case <-b.done:
s := b.cacheState
stat := newStatistics(tw, s)
var r io.Reader
if b.recoveredPanic == nil { if b.recoveredPanic == nil {
r = s.draw(stat) reader = s.draw(stat)
} }
reader, lines := s.extender(r, s.reqWidth, stat) reader, lines = s.extender(reader, s.reqWidth, stat)
b.frameCh <- &frame{reader, lines + 1}
}
}
func (b *Bar) subscribeDecorators() {
var averageDecorators []decor.AverageDecorator
var ewmaDecorators []decor.EwmaDecorator
var shutdownListeners []decor.ShutdownListener
b.TraverseDecorators(func(d decor.Decorator) {
if d, ok := d.(decor.AverageDecorator); ok {
averageDecorators = append(averageDecorators, d)
}
if d, ok := d.(decor.EwmaDecorator); ok {
ewmaDecorators = append(ewmaDecorators, d)
}
if d, ok := d.(decor.ShutdownListener); ok {
shutdownListeners = append(shutdownListeners, d)
}
})
b.hasEwmaDecorators = len(ewmaDecorators) != 0
select {
case b.operateState <- func(s *bState) {
s.averageDecorators = averageDecorators
s.ewmaDecorators = ewmaDecorators
s.shutdownListeners = shutdownListeners
}: }:
case <-b.done: case <-b.done:
var reader io.Reader
var lines int
stat, s := newStatistics(tw, b.bs), b.bs
if b.recoveredPanic == nil {
reader = s.draw(stat)
}
reader, lines = s.extender(reader, s.reqWidth, stat)
b.frameCh <- &renderFrame{
reader: reader,
lines: lines + 1,
}
} }
} }
func (b *Bar) forceRefreshIfLastUncompleted() { func (b *Bar) forceRefresh() {
var uncompleted int var anyOtherRunning bool
b.container.traverseBars(func(bar *Bar) bool { b.container.traverseBars(func(bar *Bar) bool {
if b != bar && !bar.Completed() { anyOtherRunning = b != bar && bar.isRunning()
uncompleted++ return !anyOtherRunning
return false
}
return true
}) })
if uncompleted == 0 { if !anyOtherRunning {
for { for {
select { select {
case b.container.refreshCh <- time.Now(): case b.container.refreshCh <- time.Now():
time.Sleep(prr)
case <-b.done: case <-b.done:
return return
} }
@ -417,13 +422,25 @@ func (b *Bar) forceRefreshIfLastUncompleted() {
} }
} }
func (b *Bar) isRunning() bool {
result := make(chan bool)
select {
case b.operateState <- func(s *bState) {
result <- !s.completed && !s.aborted
}:
return <-result
case <-b.done:
return false
}
}
func (b *Bar) wSyncTable() [][]chan int { func (b *Bar) wSyncTable() [][]chan int {
result := make(chan [][]chan int) result := make(chan [][]chan int)
select { select {
case b.operateState <- func(s *bState) { result <- s.wSyncTable() }: case b.operateState <- func(s *bState) { result <- s.wSyncTable() }:
return <-result return <-result
case <-b.done: case <-b.done:
return b.cacheState.wSyncTable() return b.bs.wSyncTable()
} }
} }
@ -487,6 +504,26 @@ func (s *bState) wSyncTable() [][]chan int {
return table return table
} }
func (s *bState) subscribeDecorators() {
for _, decorators := range [...][]decor.Decorator{
s.pDecorators,
s.aDecorators,
} {
for _, d := range decorators {
d = extractBaseDecorator(d)
if d, ok := d.(decor.AverageDecorator); ok {
s.averageDecorators = append(s.averageDecorators, d)
}
if d, ok := d.(decor.EwmaDecorator); ok {
s.ewmaDecorators = append(s.ewmaDecorators, d)
}
if d, ok := d.(decor.ShutdownListener); ok {
s.shutdownListeners = append(s.shutdownListeners, d)
}
}
}
}
func (s bState) decoratorEwmaUpdate(dur time.Duration) { func (s bState) decoratorEwmaUpdate(dur time.Duration) {
wg := new(sync.WaitGroup) wg := new(sync.WaitGroup)
for i := 0; i < len(s.ewmaDecorators); i++ { for i := 0; i < len(s.ewmaDecorators); i++ {
@ -540,12 +577,12 @@ func (s bState) decoratorShutdownNotify() {
func newStatistics(tw int, s *bState) decor.Statistics { func newStatistics(tw int, s *bState) decor.Statistics {
return decor.Statistics{ return decor.Statistics{
ID: s.id,
AvailableWidth: tw, AvailableWidth: tw,
ID: s.id,
Total: s.total, Total: s.total,
Current: s.current, Current: s.current,
Refill: s.refill, Refill: s.refill,
Completed: s.completeFlushed, Completed: s.completed,
Aborted: s.aborted, Aborted: s.aborted,
} }
} }

View File

@ -157,9 +157,8 @@ func (s *bFiller) Fill(w io.Writer, width int, stat decor.Statistics) {
return return
} }
ow := optimisticWriter(w) mustWrite(w, s.components[iLbound].bytes)
ow(s.components[iLbound].bytes) defer mustWrite(w, s.components[iRbound].bytes)
defer ow(s.components[iRbound].bytes)
if width == 0 { if width == 0 {
return return
@ -231,26 +230,24 @@ func (s *bFiller) Fill(w io.Writer, width int, stat decor.Statistics) {
} }
if s.rev { if s.rev {
flush(ow, padding, filling) flush(w, padding, filling)
} else { } else {
flush(ow, filling, padding) flush(w, filling, padding)
} }
} }
func flush(ow func([]byte), filling, padding [][]byte) { func flush(w io.Writer, filling, padding [][]byte) {
for i := len(filling) - 1; i >= 0; i-- { for i := len(filling) - 1; i >= 0; i-- {
ow(filling[i]) mustWrite(w, filling[i])
} }
for i := 0; i < len(padding); i++ { for i := 0; i < len(padding); i++ {
ow(padding[i]) mustWrite(w, padding[i])
} }
} }
func optimisticWriter(w io.Writer) func([]byte) { func mustWrite(w io.Writer, p []byte) {
return func(p []byte) { _, err := w.Write(p)
_, err := w.Write(p) if err != nil {
if err != nil { panic(err)
panic(err)
}
} }
} }

View File

@ -59,14 +59,17 @@ func BarWidth(width int) BarOption {
} }
} }
// BarQueueAfter queues this (being constructed) bar to relplace // BarQueueAfter puts this (being constructed) bar into the queue.
// runningBar after it has been completed. // When argument bar completes or aborts queued bar replaces its place.
func BarQueueAfter(runningBar *Bar) BarOption { // If sync is true queued bar is suspended until argument bar completes
if runningBar == nil { // or aborts.
func BarQueueAfter(bar *Bar, sync bool) BarOption {
if bar == nil {
return nil return nil
} }
return func(s *bState) { return func(s *bState) {
s.runningBar = runningBar s.afterBar = bar
s.sync = sync
} }
} }

View File

@ -11,7 +11,7 @@ import (
// ErrNotTTY not a TeleTYpewriter error. // ErrNotTTY not a TeleTYpewriter error.
var ErrNotTTY = errors.New("not a terminal") var ErrNotTTY = errors.New("not a terminal")
// http://ascii-table.com/ansi-escape-sequences.php // https://github.com/dylanaraps/pure-sh-bible#cursor-movement
const ( const (
escOpen = "\x1b[" escOpen = "\x1b["
cuuAndEd = "A\x1b[J" cuuAndEd = "A\x1b[J"

View File

@ -47,8 +47,8 @@ const (
// Statistics consists of progress related statistics, that Decorator // Statistics consists of progress related statistics, that Decorator
// may need. // may need.
type Statistics struct { type Statistics struct {
ID int
AvailableWidth int AvailableWidth int
ID int
Total int64 Total int64
Current int64 Current int64
Refill int64 Refill int64

View File

@ -2,11 +2,9 @@ package decor
import "io" import "io"
func optimisticStringWriter(w io.Writer) func(string) { func mustWriteString(w io.Writer, s string) {
return func(s string) { _, err := io.WriteString(w, s)
_, err := io.WriteString(w, s) if err != nil {
if err != nil { panic(err)
panic(err)
}
} }
} }

View File

@ -23,12 +23,11 @@ func (s percentageType) Format(st fmt.State, verb rune) {
} }
} }
osw := optimisticStringWriter(st) mustWriteString(st, strconv.FormatFloat(float64(s), 'f', prec, 64))
osw(strconv.FormatFloat(float64(s), 'f', prec, 64))
if st.Flag(' ') { if st.Flag(' ') {
osw(" ") mustWriteString(st, " ")
} }
osw("%") mustWriteString(st, "%")
} }
// Percentage returns percentage decorator. It's a wrapper of NewPercentage. // Percentage returns percentage decorator. It's a wrapper of NewPercentage.

View File

@ -49,12 +49,11 @@ func (self SizeB1024) Format(st fmt.State, verb rune) {
unit = _iTiB unit = _iTiB
} }
osw := optimisticStringWriter(st) mustWriteString(st, strconv.FormatFloat(float64(self)/float64(unit), 'f', prec, 64))
osw(strconv.FormatFloat(float64(self)/float64(unit), 'f', prec, 64))
if st.Flag(' ') { if st.Flag(' ') {
osw(" ") mustWriteString(st, " ")
} }
osw(unit.String()) mustWriteString(st, unit.String())
} }
const ( const (
@ -98,10 +97,9 @@ func (self SizeB1000) Format(st fmt.State, verb rune) {
unit = _TB unit = _TB
} }
osw := optimisticStringWriter(st) mustWriteString(st, strconv.FormatFloat(float64(self)/float64(unit), 'f', prec, 64))
osw(strconv.FormatFloat(float64(self)/float64(unit), 'f', prec, 64))
if st.Flag(' ') { if st.Flag(' ') {
osw(" ") mustWriteString(st, " ")
} }
osw(unit.String()) mustWriteString(st, unit.String())
} }

View File

@ -23,7 +23,7 @@ type speedFormatter struct {
func (self *speedFormatter) Format(st fmt.State, verb rune) { func (self *speedFormatter) Format(st fmt.State, verb rune) {
self.Formatter.Format(st, verb) self.Formatter.Format(st, verb)
optimisticStringWriter(st)("/s") mustWriteString(st, "/s")
} }
// EwmaSpeed exponential-weighted-moving-average based speed decorator. // EwmaSpeed exponential-weighted-moving-average based speed decorator.

View File

@ -4,7 +4,7 @@ require (
github.com/VividCortex/ewma v1.2.0 github.com/VividCortex/ewma v1.2.0
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d
github.com/mattn/go-runewidth v0.0.13 github.com/mattn/go-runewidth v0.0.13
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 golang.org/x/sys v0.0.0-20220209214540-3681064d5158
) )
go 1.14 go 1.14

View File

@ -6,5 +6,5 @@ github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4
github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 h1:XfKQ4OlFl8okEOr5UvAqFRVj8pY/4yfcXrddB8qAbU0= golang.org/x/sys v0.0.0-20220209214540-3681064d5158 h1:rm+CHSpPEEW2IsXUib1ThaHIjuBVZjxNgSKmBLFfD4c=
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=

View File

@ -16,12 +16,10 @@ import (
) )
const ( const (
// default RefreshRate prr = 150 * time.Millisecond // default RefreshRate
prr = 150 * time.Millisecond
) )
// Progress represents a container that renders one or more progress // Progress represents a container that renders one or more progress bars.
// bars.
type Progress struct { type Progress struct {
ctx context.Context ctx context.Context
uwg *sync.WaitGroup uwg *sync.WaitGroup
@ -33,14 +31,12 @@ type Progress struct {
once sync.Once once sync.Once
} }
// pState holds bars in its priorityQueue. It gets passed to // pState holds bars in its priorityQueue, it gets passed to (*Progress).serve monitor goroutine.
// *Progress.serve(...) monitor goroutine.
type pState struct { type pState struct {
bHeap priorityQueue bHeap priorityQueue
heapUpdated bool heapUpdated bool
pMatrix map[int][]chan int pMatrix map[int][]chan int
aMatrix map[int][]chan int aMatrix map[int][]chan int
barShutdownQueue []*Bar
// following are provided/overrided by user // following are provided/overrided by user
idCount int idCount int
@ -52,26 +48,26 @@ type pState struct {
externalRefresh <-chan interface{} externalRefresh <-chan interface{}
renderDelay <-chan struct{} renderDelay <-chan struct{}
shutdownNotifier chan struct{} shutdownNotifier chan struct{}
parkedBars map[*Bar]*Bar queueBars map[*Bar]*Bar
output io.Writer output io.Writer
debugOut io.Writer debugOut io.Writer
} }
// New creates new Progress container instance. It's not possible to // New creates new Progress container instance. It's not possible to
// reuse instance after *Progress.Wait() method has been called. // reuse instance after (*Progress).Wait method has been called.
func New(options ...ContainerOption) *Progress { func New(options ...ContainerOption) *Progress {
return NewWithContext(context.Background(), options...) return NewWithContext(context.Background(), options...)
} }
// NewWithContext creates new Progress container instance with provided // NewWithContext creates new Progress container instance with provided
// context. It's not possible to reuse instance after *Progress.Wait() // context. It's not possible to reuse instance after (*Progress).Wait
// method has been called. // method has been called.
func NewWithContext(ctx context.Context, options ...ContainerOption) *Progress { func NewWithContext(ctx context.Context, options ...ContainerOption) *Progress {
s := &pState{ s := &pState{
bHeap: priorityQueue{}, bHeap: priorityQueue{},
rr: prr, rr: prr,
parkedBars: make(map[*Bar]*Bar), queueBars: make(map[*Bar]*Bar),
output: os.Stdout, output: os.Stdout,
} }
for _, opt := range options { for _, opt := range options {
@ -110,8 +106,8 @@ func (p *Progress) New(total int64, builder BarFillerBuilder, options ...BarOpti
} }
// Add creates a bar which renders itself by provided filler. // Add creates a bar which renders itself by provided filler.
// If `total <= 0` trigger complete event is disabled until reset with *bar.SetTotal(int64, bool). // If `total <= 0` triggering complete event by increment methods is disabled.
// Panics if *Progress instance is done, i.e. called after *Progress.Wait(). // Panics if *Progress instance is done, i.e. called after (*Progress).Wait().
func (p *Progress) Add(total int64, filler BarFiller, options ...BarOption) *Bar { func (p *Progress) Add(total int64, filler BarFiller, options ...BarOption) *Bar {
if filler == nil { if filler == nil {
filler = NopStyle().Build() filler = NopStyle().Build()
@ -122,9 +118,8 @@ func (p *Progress) Add(total int64, filler BarFiller, options ...BarOption) *Bar
case p.operateState <- func(ps *pState) { case p.operateState <- func(ps *pState) {
bs := ps.makeBarState(total, filler, options...) bs := ps.makeBarState(total, filler, options...)
bar := newBar(p, bs) bar := newBar(p, bs)
if bs.runningBar != nil { if bs.afterBar != nil {
bs.runningBar.noPop = true ps.queueBars[bs.afterBar] = bar
ps.parkedBars[bs.runningBar] = bar
} else { } else {
heap.Push(&ps.bHeap, bar) heap.Push(&ps.bHeap, bar)
ps.heapUpdated = true ps.heapUpdated = true
@ -133,7 +128,6 @@ func (p *Progress) Add(total int64, filler BarFiller, options ...BarOption) *Bar
result <- bar result <- bar
}: }:
bar := <-result bar := <-result
bar.subscribeDecorators()
return bar return bar
case <-p.done: case <-p.done:
p.bwg.Done() p.bwg.Done()
@ -141,21 +135,8 @@ func (p *Progress) Add(total int64, filler BarFiller, options ...BarOption) *Bar
} }
} }
func (p *Progress) dropBar(b *Bar) {
select {
case p.operateState <- func(s *pState) {
if b.index < 0 {
return
}
heap.Remove(&s.bHeap, b.index)
s.heapUpdated = true
}:
case <-p.done:
}
}
func (p *Progress) traverseBars(cb func(b *Bar) bool) { func (p *Progress) traverseBars(cb func(b *Bar) bool) {
done := make(chan struct{}) sync := make(chan struct{})
select { select {
case p.operateState <- func(s *pState) { case p.operateState <- func(s *pState) {
for i := 0; i < s.bHeap.Len(); i++ { for i := 0; i < s.bHeap.Len(); i++ {
@ -164,9 +145,9 @@ func (p *Progress) traverseBars(cb func(b *Bar) bool) {
break break
} }
} }
close(done) close(sync)
}: }:
<-done <-sync
case <-p.done: case <-p.done:
} }
} }
@ -200,8 +181,8 @@ func (p *Progress) BarCount() int {
// After this method has been called, there is no way to reuse *Progress // After this method has been called, there is no way to reuse *Progress
// instance. // instance.
func (p *Progress) Wait() { func (p *Progress) Wait() {
// wait for user wg, if any
if p.uwg != nil { if p.uwg != nil {
// wait for user wg
p.uwg.Wait() p.uwg.Wait()
} }
@ -256,6 +237,64 @@ func (p *Progress) serve(s *pState, cw *cwriter.Writer) {
} }
} }
func (s *pState) render(cw *cwriter.Writer) error {
if s.heapUpdated {
s.updateSyncMatrix()
s.heapUpdated = false
}
syncWidth(s.pMatrix)
syncWidth(s.aMatrix)
tw, err := cw.GetWidth()
if err != nil {
tw = s.reqWidth
}
for i := 0; i < s.bHeap.Len(); i++ {
bar := s.bHeap[i]
go bar.render(tw)
}
return s.flush(cw)
}
func (s *pState) flush(cw *cwriter.Writer) error {
var lines int
pool := make([]*Bar, 0, s.bHeap.Len())
for s.bHeap.Len() > 0 {
b := heap.Pop(&s.bHeap).(*Bar)
frame := <-b.frameCh
lines += frame.lines
_, err := cw.ReadFrom(frame.reader)
if err != nil {
return err
}
if frame.shutdown {
b.Wait() // waiting for b.done, so it's safe to read b.bs
var toDrop bool
if qb, ok := s.queueBars[b]; ok {
delete(s.queueBars, b)
qb.priority = b.priority
pool = append(pool, qb)
toDrop = true
} else if s.popCompleted && !b.bs.noPop {
lines -= frame.lines
toDrop = true
}
if toDrop || b.bs.dropOnComplete {
s.heapUpdated = true
continue
}
}
pool = append(pool, b)
}
for _, b := range pool {
heap.Push(&s.bHeap, b)
}
return cw.Flush(lines)
}
func (s *pState) newTicker(done <-chan struct{}) chan time.Time { func (s *pState) newTicker(done <-chan struct{}) chan time.Time {
ch := make(chan time.Time) ch := make(chan time.Time)
if s.shutdownNotifier == nil { if s.shutdownNotifier == nil {
@ -294,78 +333,6 @@ func (s *pState) newTicker(done <-chan struct{}) chan time.Time {
return ch return ch
} }
func (s *pState) render(cw *cwriter.Writer) error {
if s.heapUpdated {
s.updateSyncMatrix()
s.heapUpdated = false
}
syncWidth(s.pMatrix)
syncWidth(s.aMatrix)
tw, err := cw.GetWidth()
if err != nil {
tw = s.reqWidth
}
for i := 0; i < s.bHeap.Len(); i++ {
bar := s.bHeap[i]
go bar.render(tw)
}
return s.flush(cw)
}
func (s *pState) flush(cw *cwriter.Writer) error {
var totalLines int
bm := make(map[*Bar]int, s.bHeap.Len())
for s.bHeap.Len() > 0 {
b := heap.Pop(&s.bHeap).(*Bar)
frame := <-b.frameCh
_, err := cw.ReadFrom(frame.reader)
if err != nil {
return err
}
if b.toShutdown {
if b.recoveredPanic != nil {
s.barShutdownQueue = append(s.barShutdownQueue, b)
b.toShutdown = false
} else {
// shutdown at next flush
// this ensures no bar ends up with less than 100% rendered
defer func() {
s.barShutdownQueue = append(s.barShutdownQueue, b)
}()
}
}
bm[b] = frame.lines
totalLines += frame.lines
}
for _, b := range s.barShutdownQueue {
if parkedBar := s.parkedBars[b]; parkedBar != nil {
parkedBar.priority = b.priority
heap.Push(&s.bHeap, parkedBar)
delete(s.parkedBars, b)
b.toDrop = true
}
if s.popCompleted && !b.noPop {
totalLines -= bm[b]
b.toDrop = true
}
if b.toDrop {
delete(bm, b)
s.heapUpdated = true
}
b.cancel()
}
s.barShutdownQueue = s.barShutdownQueue[0:0]
for b := range bm {
heap.Push(&s.bHeap, b)
}
return cw.Flush(totalLines)
}
func (s *pState) updateSyncMatrix() { func (s *pState) updateSyncMatrix() {
s.pMatrix = make(map[int][]chan int) s.pMatrix = make(map[int][]chan int)
s.aMatrix = make(map[int][]chan int) s.aMatrix = make(map[int][]chan int)
@ -418,6 +385,8 @@ func (s *pState) makeBarState(total int64, filler BarFiller, options ...BarOptio
bs.buffers[i] = bytes.NewBuffer(make([]byte, 0, 512)) bs.buffers[i] = bytes.NewBuffer(make([]byte, 0, 512))
} }
bs.subscribeDecorators()
return bs return bs
} }
@ -427,7 +396,7 @@ func syncWidth(matrix map[int][]chan int) {
} }
} }
var maxWidthDistributor = func(column []chan int) { func maxWidthDistributor(column []chan int) {
var maxWidth int var maxWidth int
for _, ch := range column { for _, ch := range column {
if w := <-ch; w > maxWidth { if w := <-ch; w > maxWidth {

View File

@ -14,9 +14,6 @@ type proxyReader struct {
func (x proxyReader) Read(p []byte) (int, error) { func (x proxyReader) Read(p []byte) (int, error) {
n, err := x.ReadCloser.Read(p) n, err := x.ReadCloser.Read(p)
x.bar.IncrBy(n) x.bar.IncrBy(n)
if err == io.EOF {
go x.bar.SetTotal(-1, true)
}
return n, err return n, err
} }
@ -28,9 +25,6 @@ type proxyWriterTo struct {
func (x proxyWriterTo) WriteTo(w io.Writer) (int64, error) { func (x proxyWriterTo) WriteTo(w io.Writer) (int64, error) {
n, err := x.wt.WriteTo(w) n, err := x.wt.WriteTo(w)
x.bar.IncrInt64(n) x.bar.IncrInt64(n)
if err == io.EOF {
go x.bar.SetTotal(-1, true)
}
return n, err return n, err
} }
@ -65,12 +59,12 @@ func (b *Bar) newProxyReader(r io.Reader) (rc io.ReadCloser) {
pr := proxyReader{toReadCloser(r), b} pr := proxyReader{toReadCloser(r), b}
if wt, ok := r.(io.WriterTo); ok { if wt, ok := r.(io.WriterTo); ok {
pw := proxyWriterTo{pr, wt} pw := proxyWriterTo{pr, wt}
if b.hasEwmaDecorators { if b.hasEwma {
rc = ewmaProxyWriterTo{ewmaProxyReader{pr}, pw} rc = ewmaProxyWriterTo{ewmaProxyReader{pr}, pw}
} else { } else {
rc = pw rc = pw
} }
} else if b.hasEwmaDecorators { } else if b.hasEwma {
rc = ewmaProxyReader{pr} rc = ewmaProxyReader{pr}
} else { } else {
rc = pr rc = pr

View File

@ -597,6 +597,7 @@ ccflags="$@"
$2 ~ /^DEVLINK_/ || $2 ~ /^DEVLINK_/ ||
$2 ~ /^ETHTOOL_/ || $2 ~ /^ETHTOOL_/ ||
$2 ~ /^LWTUNNEL_IP/ || $2 ~ /^LWTUNNEL_IP/ ||
$2 ~ /^ITIMER_/ ||
$2 !~ "WMESGLEN" && $2 !~ "WMESGLEN" &&
$2 ~ /^W[A-Z0-9]+$/ || $2 ~ /^W[A-Z0-9]+$/ ||
$2 ~/^PPPIOC/ || $2 ~/^PPPIOC/ ||

View File

@ -14,6 +14,7 @@ package unix
import ( import (
"encoding/binary" "encoding/binary"
"syscall" "syscall"
"time"
"unsafe" "unsafe"
) )
@ -2314,11 +2315,56 @@ type RemoteIovec struct {
//sys shmdt(addr uintptr) (err error) //sys shmdt(addr uintptr) (err error)
//sys shmget(key int, size int, flag int) (id int, err error) //sys shmget(key int, size int, flag int) (id int, err error)
//sys getitimer(which int, currValue *Itimerval) (err error)
//sys setitimer(which int, newValue *Itimerval, oldValue *Itimerval) (err error)
// MakeItimerval creates an Itimerval from interval and value durations.
func MakeItimerval(interval, value time.Duration) Itimerval {
return Itimerval{
Interval: NsecToTimeval(interval.Nanoseconds()),
Value: NsecToTimeval(value.Nanoseconds()),
}
}
// A value which may be passed to the which parameter for Getitimer and
// Setitimer.
type ItimerWhich int
// Possible which values for Getitimer and Setitimer.
const (
ItimerReal ItimerWhich = ITIMER_REAL
ItimerVirtual ItimerWhich = ITIMER_VIRTUAL
ItimerProf ItimerWhich = ITIMER_PROF
)
// Getitimer wraps getitimer(2) to return the current value of the timer
// specified by which.
func Getitimer(which ItimerWhich) (Itimerval, error) {
var it Itimerval
if err := getitimer(int(which), &it); err != nil {
return Itimerval{}, err
}
return it, nil
}
// Setitimer wraps setitimer(2) to arm or disarm the timer specified by which.
// It returns the previous value of the timer.
//
// If the Itimerval argument is the zero value, the timer will be disarmed.
func Setitimer(which ItimerWhich, it Itimerval) (Itimerval, error) {
var prev Itimerval
if err := setitimer(int(which), &it, &prev); err != nil {
return Itimerval{}, err
}
return prev, nil
}
/* /*
* Unimplemented * Unimplemented
*/ */
// AfsSyscall // AfsSyscall
// Alarm
// ArchPrctl // ArchPrctl
// Brk // Brk
// ClockNanosleep // ClockNanosleep
@ -2334,7 +2380,6 @@ type RemoteIovec struct {
// GetMempolicy // GetMempolicy
// GetRobustList // GetRobustList
// GetThreadArea // GetThreadArea
// Getitimer
// Getpmsg // Getpmsg
// IoCancel // IoCancel
// IoDestroy // IoDestroy

14
vendor/golang.org/x/sys/unix/syscall_linux_alarm.go generated vendored Normal file
View File

@ -0,0 +1,14 @@
// Copyright 2022 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//go:build linux && (386 || amd64 || mips || mipsle || mips64 || mipsle || ppc64 || ppc64le || ppc || s390x || sparc64)
// +build linux
// +build 386 amd64 mips mipsle mips64 mipsle ppc64 ppc64le ppc s390x sparc64
package unix
// SYS_ALARM is not defined on arm or riscv, but is available for other GOARCH
// values.
//sys Alarm(seconds uint) (remaining uint, err error)

View File

@ -38,7 +38,8 @@ const (
AF_KEY = 0xf AF_KEY = 0xf
AF_LLC = 0x1a AF_LLC = 0x1a
AF_LOCAL = 0x1 AF_LOCAL = 0x1
AF_MAX = 0x2d AF_MAX = 0x2e
AF_MCTP = 0x2d
AF_MPLS = 0x1c AF_MPLS = 0x1c
AF_NETBEUI = 0xd AF_NETBEUI = 0xd
AF_NETLINK = 0x10 AF_NETLINK = 0x10
@ -1267,6 +1268,9 @@ const (
IP_XFRM_POLICY = 0x11 IP_XFRM_POLICY = 0x11
ISOFS_SUPER_MAGIC = 0x9660 ISOFS_SUPER_MAGIC = 0x9660
ISTRIP = 0x20 ISTRIP = 0x20
ITIMER_PROF = 0x2
ITIMER_REAL = 0x0
ITIMER_VIRTUAL = 0x1
IUTF8 = 0x4000 IUTF8 = 0x4000
IXANY = 0x800 IXANY = 0x800
JFFS2_SUPER_MAGIC = 0x72b6 JFFS2_SUPER_MAGIC = 0x72b6

View File

@ -2032,3 +2032,23 @@ func shmget(key int, size int, flag int) (id int, err error) {
} }
return return
} }
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func getitimer(which int, currValue *Itimerval) (err error) {
_, _, e1 := Syscall(SYS_GETITIMER, uintptr(which), uintptr(unsafe.Pointer(currValue)), 0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func setitimer(which int, newValue *Itimerval, oldValue *Itimerval) (err error) {
_, _, e1 := Syscall(SYS_SETITIMER, uintptr(which), uintptr(unsafe.Pointer(newValue)), uintptr(unsafe.Pointer(oldValue)))
if e1 != 0 {
err = errnoErr(e1)
}
return
}

View File

@ -1,4 +1,4 @@
// go run mksyscall.go -l32 -tags linux,386 syscall_linux.go syscall_linux_386.go // go run mksyscall.go -l32 -tags linux,386 syscall_linux.go syscall_linux_386.go syscall_linux_alarm.go
// Code generated by the command above; see README.md. DO NOT EDIT. // Code generated by the command above; see README.md. DO NOT EDIT.
//go:build linux && 386 //go:build linux && 386
@ -524,3 +524,14 @@ func utimes(path string, times *[2]Timeval) (err error) {
} }
return return
} }
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Alarm(seconds uint) (remaining uint, err error) {
r0, _, e1 := Syscall(SYS_ALARM, uintptr(seconds), 0, 0)
remaining = uint(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}

View File

@ -1,4 +1,4 @@
// go run mksyscall.go -tags linux,amd64 syscall_linux.go syscall_linux_amd64.go // go run mksyscall.go -tags linux,amd64 syscall_linux.go syscall_linux_amd64.go syscall_linux_alarm.go
// Code generated by the command above; see README.md. DO NOT EDIT. // Code generated by the command above; see README.md. DO NOT EDIT.
//go:build linux && amd64 //go:build linux && amd64
@ -691,3 +691,14 @@ func kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, f
} }
return return
} }
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Alarm(seconds uint) (remaining uint, err error) {
r0, _, e1 := Syscall(SYS_ALARM, uintptr(seconds), 0, 0)
remaining = uint(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}

View File

@ -1,4 +1,4 @@
// go run mksyscall.go -b32 -arm -tags linux,mips syscall_linux.go syscall_linux_mipsx.go // go run mksyscall.go -b32 -arm -tags linux,mips syscall_linux.go syscall_linux_mipsx.go syscall_linux_alarm.go
// Code generated by the command above; see README.md. DO NOT EDIT. // Code generated by the command above; see README.md. DO NOT EDIT.
//go:build linux && mips //go:build linux && mips
@ -702,3 +702,14 @@ func setrlimit(resource int, rlim *rlimit32) (err error) {
} }
return return
} }
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Alarm(seconds uint) (remaining uint, err error) {
r0, _, e1 := Syscall(SYS_ALARM, uintptr(seconds), 0, 0)
remaining = uint(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}

View File

@ -1,4 +1,4 @@
// go run mksyscall.go -tags linux,mips64 syscall_linux.go syscall_linux_mips64x.go // go run mksyscall.go -tags linux,mips64 syscall_linux.go syscall_linux_mips64x.go syscall_linux_alarm.go
// Code generated by the command above; see README.md. DO NOT EDIT. // Code generated by the command above; see README.md. DO NOT EDIT.
//go:build linux && mips64 //go:build linux && mips64
@ -696,3 +696,14 @@ func stat(path string, st *stat_t) (err error) {
} }
return return
} }
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Alarm(seconds uint) (remaining uint, err error) {
r0, _, e1 := Syscall(SYS_ALARM, uintptr(seconds), 0, 0)
remaining = uint(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}

View File

@ -1,4 +1,4 @@
// go run mksyscall.go -l32 -arm -tags linux,mipsle syscall_linux.go syscall_linux_mipsx.go // go run mksyscall.go -l32 -arm -tags linux,mipsle syscall_linux.go syscall_linux_mipsx.go syscall_linux_alarm.go
// Code generated by the command above; see README.md. DO NOT EDIT. // Code generated by the command above; see README.md. DO NOT EDIT.
//go:build linux && mipsle //go:build linux && mipsle
@ -702,3 +702,14 @@ func setrlimit(resource int, rlim *rlimit32) (err error) {
} }
return return
} }
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Alarm(seconds uint) (remaining uint, err error) {
r0, _, e1 := Syscall(SYS_ALARM, uintptr(seconds), 0, 0)
remaining = uint(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}

View File

@ -1,4 +1,4 @@
// go run mksyscall.go -b32 -tags linux,ppc syscall_linux.go syscall_linux_ppc.go // go run mksyscall.go -b32 -tags linux,ppc syscall_linux.go syscall_linux_ppc.go syscall_linux_alarm.go
// Code generated by the command above; see README.md. DO NOT EDIT. // Code generated by the command above; see README.md. DO NOT EDIT.
//go:build linux && ppc //go:build linux && ppc
@ -707,3 +707,14 @@ func kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, f
} }
return return
} }
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Alarm(seconds uint) (remaining uint, err error) {
r0, _, e1 := Syscall(SYS_ALARM, uintptr(seconds), 0, 0)
remaining = uint(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}

View File

@ -1,4 +1,4 @@
// go run mksyscall.go -tags linux,ppc64 syscall_linux.go syscall_linux_ppc64x.go // go run mksyscall.go -tags linux,ppc64 syscall_linux.go syscall_linux_ppc64x.go syscall_linux_alarm.go
// Code generated by the command above; see README.md. DO NOT EDIT. // Code generated by the command above; see README.md. DO NOT EDIT.
//go:build linux && ppc64 //go:build linux && ppc64
@ -753,3 +753,14 @@ func kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, f
} }
return return
} }
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Alarm(seconds uint) (remaining uint, err error) {
r0, _, e1 := Syscall(SYS_ALARM, uintptr(seconds), 0, 0)
remaining = uint(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}

View File

@ -1,4 +1,4 @@
// go run mksyscall.go -tags linux,ppc64le syscall_linux.go syscall_linux_ppc64x.go // go run mksyscall.go -tags linux,ppc64le syscall_linux.go syscall_linux_ppc64x.go syscall_linux_alarm.go
// Code generated by the command above; see README.md. DO NOT EDIT. // Code generated by the command above; see README.md. DO NOT EDIT.
//go:build linux && ppc64le //go:build linux && ppc64le
@ -753,3 +753,14 @@ func kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, f
} }
return return
} }
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Alarm(seconds uint) (remaining uint, err error) {
r0, _, e1 := Syscall(SYS_ALARM, uintptr(seconds), 0, 0)
remaining = uint(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}

View File

@ -1,4 +1,4 @@
// go run mksyscall.go -tags linux,s390x syscall_linux.go syscall_linux_s390x.go // go run mksyscall.go -tags linux,s390x syscall_linux.go syscall_linux_s390x.go syscall_linux_alarm.go
// Code generated by the command above; see README.md. DO NOT EDIT. // Code generated by the command above; see README.md. DO NOT EDIT.
//go:build linux && s390x //go:build linux && s390x
@ -533,3 +533,14 @@ func kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, f
} }
return return
} }
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Alarm(seconds uint) (remaining uint, err error) {
r0, _, e1 := Syscall(SYS_ALARM, uintptr(seconds), 0, 0)
remaining = uint(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}

View File

@ -1,4 +1,4 @@
// go run mksyscall.go -tags linux,sparc64 syscall_linux.go syscall_linux_sparc64.go // go run mksyscall.go -tags linux,sparc64 syscall_linux.go syscall_linux_sparc64.go syscall_linux_alarm.go
// Code generated by the command above; see README.md. DO NOT EDIT. // Code generated by the command above; see README.md. DO NOT EDIT.
//go:build linux && sparc64 //go:build linux && sparc64
@ -697,3 +697,14 @@ func utimes(path string, times *[2]Timeval) (err error) {
} }
return return
} }
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
func Alarm(seconds uint) (remaining uint, err error) {
r0, _, e1 := Syscall(SYS_ALARM, uintptr(seconds), 0, 0)
remaining = uint(r0)
if e1 != 0 {
err = errnoErr(e1)
}
return
}

View File

@ -24,6 +24,11 @@ type ItimerSpec struct {
Value Timespec Value Timespec
} }
type Itimerval struct {
Interval Timeval
Value Timeval
}
const ( const (
TIME_OK = 0x0 TIME_OK = 0x0
TIME_INS = 0x1 TIME_INS = 0x1

4
vendor/modules.txt vendored
View File

@ -683,7 +683,7 @@ github.com/ulikunitz/xz/lzma
github.com/vbatts/tar-split/archive/tar github.com/vbatts/tar-split/archive/tar
github.com/vbatts/tar-split/tar/asm github.com/vbatts/tar-split/tar/asm
github.com/vbatts/tar-split/tar/storage github.com/vbatts/tar-split/tar/storage
# github.com/vbauerster/mpb/v7 v7.3.2 # github.com/vbauerster/mpb/v7 v7.4.1
## explicit ## explicit
github.com/vbauerster/mpb/v7 github.com/vbauerster/mpb/v7
github.com/vbauerster/mpb/v7/cwriter github.com/vbauerster/mpb/v7/cwriter
@ -750,7 +750,7 @@ golang.org/x/net/trace
## explicit ## explicit
golang.org/x/sync/errgroup golang.org/x/sync/errgroup
golang.org/x/sync/semaphore golang.org/x/sync/semaphore
# golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27 # golang.org/x/sys v0.0.0-20220209214540-3681064d5158
## explicit ## explicit
golang.org/x/sys/cpu golang.org/x/sys/cpu
golang.org/x/sys/execabs golang.org/x/sys/execabs