Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ScanProgress ¶
type ScanProgress struct {
// contains filtered or unexported fields
}
ScanProgress is a type that's used for tracking current running scans, listen to their progress events and invoke cancellations or "done" signals. This allows throttling or canceling previous scans instead of having many scans running at once for the same files.
The correct usage would be to create a NewScanProgress and call "go Listen()" to listen for cancel/done signals in the background. ScanProgress operations should be done in locked sections.
func NewScanProgress ¶
func NewScanProgress() *ScanProgress
func (*ScanProgress) CancelScan ¶
func (sp *ScanProgress) CancelScan()
func (*ScanProgress) GetCancelChannel ¶
func (sp *ScanProgress) GetCancelChannel() <-chan bool
func (*ScanProgress) GetDoneChannel ¶
func (sp *ScanProgress) GetDoneChannel() <-chan bool
func (*ScanProgress) IsDone ¶
func (sp *ScanProgress) IsDone() bool
IsDone is true if the scan finished whether by cancellation or by a SetDone call
func (*ScanProgress) Listen ¶
func (sp *ScanProgress) Listen(cancel context.CancelFunc, scanNumber int)
Listen waits for cancel or done signals until one of them is received. If the cancel signal is received, the cancel function will be called. Listen stops after the first signal is processed.
func (*ScanProgress) SetDone ¶
func (sp *ScanProgress) SetDone()
SetDone will mark the ScanProgress as done and send a message to the "done" channel. It is safe to call SetDone repeatedly, or after CancelScan was called, so it's ok to defer a function that calls SetDone in a locked section.