Documentation
¶
Overview ¶
Package loadingBar provides a command line based, non-blocking loading bar.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LoadingBar ¶
type LoadingBar struct {
// contains filtered or unexported fields
}
LoadingBar is a structure which holds all components to provide the loading bar.
currentStatusChans []chan int - the channels via which functions can report the current status maxStatuses []int - thw maximum capacity of each channel getChanSemaphore *semaphore.Weighted - a semaphore controlling parallel access on the channels chansToAcquire []chan int - channels which aren't already used to report a status stopLoadingBar bool - true if the loading bar shouldn't be shown anymore loadingBarStopped bool - true if the loading bar isn't shown anymore
func InitLoadingBar ¶
func InitLoadingBar(numberOfStatuses int, maxInitStatuses ...int) (loadingBar *LoadingBar)
InitLoadingBar is a constructor for the LoadingBar structure.
Takes:
numberOfStatuses int - the number of status channels needed for the loading bar one status channel is needed for each part of the program that should report to the same loading bar maxInitStatuses ...int - the size of each status channel, should accommodate the number of values reported to the channel, so it won't block
Returns:
loadingBar *LoadingBar - a pointer to the created LoadingBar struct
func (*LoadingBar) GetStatusChanWithCapacity ¶
func (loadingBar *LoadingBar) GetStatusChanWithCapacity(capacity int) (currentStatusChan chan int, err error)
GetStatusChanWithCapacity is a public function which provide an acquirable channel with a given capacity. Provide integers that are counting up after RunLoadingBar was called to let the loading bar count up.
Operates on:
loadingBar *LoadingBar - a pointer to the LoadingBar structure which provides the channels
Takes:
capacity int - the capacity the channel should have
Returns:
currentStatusChan chan int - the channel requested, nil if an error occurred err error - the error if no channel could be acquired
func (*LoadingBar) RunLoadingBar ¶
func (loadingBar *LoadingBar) RunLoadingBar()
RunLoadingBar is a public function to run and display the loading bar.
Operates on:
loadingBar *LoadingBar - a pointer to the loading bar that should be displayed
func (*LoadingBar) StopLoadingBar ¶
func (loadingBar *LoadingBar) StopLoadingBar()
StopLoadingBar is a public function to stop the loading bar and erase it from the screen.
Operates on:
loadingBar *LoadingBar - a pointer to the loading bar that should be stopped