//export sidebandProgressCallback
498574
func sidebandProgressCallback(_str *C.char, _len C.int, data unsafe.Pointer) int {
	callbacks := pointerHandles.Get(data).(*RemoteCallbacks)
	if callbacks.SidebandProgressCallback == nil {
		return 0
	}
	str := C.GoStringN(_str, _len)
	return int(callbacks.SidebandProgressCallback(str))
}
767518
func (r *progressReporter) advance(f fs.File) {
	if r.totalCount == 0 {
		return
	}

	now := clock.Now(r.ctx)
	reportNow := false
	progress := 0

	// We don't count size of the symlinks toward total.
	var size uint64
	if !f.Symlink() {
		size = f.Size()
	}

	// Report progress on first and last 'advance' calls and each 2 sec.
	r.Lock()
	r.extractedSize += size
	r.extractedCount++
	if r.extractedCount == 1 || r.extractedCount == r.totalCount || now.Sub(r.prevReport) > 2*time.Second {
		reportNow = true
		if r.totalSize != 0 {
			progress = int(float64(r.extractedSize) * 100 / float64(r.totalSize))
		} else {
			progress = int(float64(r.extractedCount) * 100 / float64(r.totalCount))
		}
		r.prevReport = now
	}
	r.Unlock()

	if reportNow {
		logging.Infof(r.ctx, "cipd: extracting - %d%%", progress)
	}
}
701440
func (exp *explorerUI) BeginSyncStatusUpdates(barLoad chan *dbtypes.ProgressBarLoad) {
	// Do not start listening for updates if channel is nil.
	if barLoad == nil {
		log.Warnf("Not updating sync status page.")
		return
	}

	// stopTimer allows safe exit of the goroutine that triggers periodic
	// websocket progress update.
	stopTimer := make(chan struct{})

	exp.EnableSyncStatusPage(true)

	// Periodically trigger websocket hub to signal a progress update.
	go func() {
		timer := time.NewTicker(syncStatusInterval)

	timerLoop:
		for {
			select {
			case <-timer.C:
				log.Trace("Sending progress bar signal.")
				exp.wsHub.HubRelay <- pstypes.HubMessage{Signal: sigSyncStatus}

			case <-stopTimer:
				log.Debug("Stopping progress bar signals.")
				timer.Stop()
				break timerLoop
			}
		}
	}()

	// Update the progress bar data when progress updates are received from the
	// sync routine of a database backend.
	go func() {
		// The receive loop quits when barLoad is closed or a nil *Hash is sent.
		// In either case, the barLoad channel is set to nil when the goroutine
		// returns. As a result, the websocket trigger goroutine will return.
		defer func() {
			log.Debug("Finished with sync status updates.")
			barLoad = nil
			// Send the one last signal so that the websocket can send the final
			// confirmation that syncing is done and home page auto reload should
			// happen.
			exp.wsHub.HubRelay <- pstypes.HubMessage{Signal: sigSyncStatus}
			exp.EnableSyncStatusPage(false)
		}()

	barloop:
		for bar := range barLoad {
			if bar == nil {
				stopTimer <- struct{}{}
				return
			}

			var percentage float64
			if bar.To > 0 {
				percentage = math.Floor(float64(bar.From)/float64(bar.To)*10000) / 100
			}

			val := SyncStatusInfo{
				PercentComplete: percentage,
				BarMsg:          bar.Msg,
				Time:            bar.Timestamp,
				ProgressBarID:   bar.BarID,
				BarSubtitle:     bar.Subtitle,
			}

			// Update existing progress bar if one is found with this ID.
			blockchainSyncStatus.Lock()
			for i, v := range blockchainSyncStatus.ProgressBars {
				if v.ProgressBarID == bar.BarID {
					// Existing progress bar data.
					if len(bar.Subtitle) > 0 && bar.Timestamp == 0 {
						// Handle case scenario when only subtitle should be updated.
						blockchainSyncStatus.ProgressBars[i].BarSubtitle = bar.Subtitle
					} else {
						blockchainSyncStatus.ProgressBars[i] = val
					}
					// Go back to waiting for updates.
					blockchainSyncStatus.Unlock()
					continue barloop
				}
			}

			// Existing bar with this ID not found, append new.
			blockchainSyncStatus.ProgressBars = append(blockchainSyncStatus.ProgressBars, val)
			blockchainSyncStatus.Unlock()
		}
	}()
}
857097
func SimpleProgressE(printChar string, tickInterval time.Duration, action func() error) error {
	var actionError error
	SimpleProgress(printChar, tickInterval, func() {
		actionError = action()
	})
	return actionError
}
1018187
func (c *Callbacks) OnCDOTAUserMsg_UpdateQuestProgress(fn func(*dota.CDOTAUserMsg_UpdateQuestProgress) error) {
	c.onCDOTAUserMsg_UpdateQuestProgress = append(c.onCDOTAUserMsg_UpdateQuestProgress, fn)
}
899698
func handleProgress(ch <-chan *migrator.ProgressUpdate, doneCh <-chan struct{}) {
	var lastOp string
	var lastProgress float64
	lastFlush := time.Now()
	for {
		select {
		case update := <-ch:
			switch {
			case lastOp != update.Op:
				lastProgress = update.Progress
				lastOp = update.Op
				fmt.Println(update.Op)
				fmt.Printf("%.2f%%\n", update.Progress)

			case update.Progress-lastProgress >= 5:
				fallthrough

			case time.Now().Sub(lastFlush) > time.Second:
				fallthrough

			case update.Progress == 100:
				lastFlush = time.Now()
				lastProgress = update.Progress
				fmt.Printf("%.2f%%\n", update.Progress)
			}
		case <-doneCh:
			return
		}
	}
}
1036935
func (c *Consumer) CountCallback(totalSize int64) counter.CountCallback {
	return func(count int64) {
		c.Progress(float64(count) / float64(totalSize))
	}
}
1032043
func SimpleProgress(printChar string, tickInterval time.Duration, action func()) {
	// run async
	finishedChan := make(chan bool)

	go func() {
		action()
		finishedChan <- true
	}()

	isRunFinished := false
	for !isRunFinished {
		select {
		case <-finishedChan:
			isRunFinished = true
		case <-time.Tick(tickInterval):
			fmt.Print(printChar)
		}
	}
	fmt.Println()
}
977274
func (c *Callbacks) OnCDOTAUserMsg_HeroRelicProgress(fn func(*dota.CDOTAUserMsg_HeroRelicProgress) error) {
	c.onCDOTAUserMsg_HeroRelicProgress = append(c.onCDOTAUserMsg_HeroRelicProgress, fn)
}
457131
func (c *Client) runCallback(callback func(*dnode.Partial), args *dnode.Partial) {
	// Do not panic no matter what.
	defer func() {
		if err := recover(); err != nil {
			c.LocalKite.Log.Warning("Error in calling the callback function : %v", err)
		}
	}()

	// Call the callback function.
	callback(args)
}
1200007
func Progress(listener func(*vecty.Event)) *vecty.EventListener {
	return &vecty.EventListener{Name: "progress", Listener: listener}
}
327461
func (out *progressOutput) WriteProgress(prog progress.Progress) error {
	var formatted []byte
	if prog.Message != "" {
		formatted = out.sf.formatStatus(prog.ID, prog.Message)
	} else {
		jsonProgress := jsonmessage.JSONProgress{Current: prog.Current, Total: prog.Total, HideCounts: prog.HideCounts, Units: prog.Units}
		formatted = out.sf.formatProgress(prog.ID, prog.Action, &jsonProgress, prog.Aux)
	}
	_, err := out.out.Write(formatted)
	if err != nil {
		return err
	}

	if out.newLines && prog.LastUpdate {
		_, err = out.out.Write(out.sf.formatStatus("", ""))
		return err
	}

	return nil
}
342758
func (u *Ui) TrackProgress(src string, currentSize, totalSize int64, stream io.ReadCloser) io.ReadCloser {
	pl := &TrackProgressParameters{
		Src:         src,
		CurrentSize: currentSize,
		TotalSize:   totalSize,
	}
	var trackingID string
	if err := u.client.Call("Ui.NewTrackProgress", pl, &trackingID); err != nil {
		log.Printf("Error in Ui.NewTrackProgress RPC call: %s", err)
		return stream
	}
	cli := &ProgressTrackingClient{
		id:     trackingID,
		client: u.client,
		stream: stream,
	}
	return cli
}
930474
func checkoutProgressCallback(path *C.char, completed_steps, total_steps C.size_t, data unsafe.Pointer) int {
	opts := pointerHandles.Get(data).(*CheckoutOpts)
	if opts.ProgressCallback == nil {
		return 0
	}
	return int(opts.ProgressCallback(C.GoString(path), uint(completed_steps), uint(total_steps)))
}
243547
func (r *BodyWithCallback) ResetProgress() error {
	return r.c(r.totalSize, r.readSize, -int(r.readSize))
}
763543
func (r Metric_Tracking_Object) GetBackboneBandwidthGraph(graphTitle *string) (resp datatypes.Container_Bandwidth_GraphOutputs, err error) {
	params := []interface{}{
		graphTitle,
	}
	err = r.Session.DoRequest("SoftLayer_Metric_Tracking_Object", "getBackboneBandwidthGraph", params, &r.Options, &resp)
	return
}
787832
func (h *DeployHandler) serveProgress(w http.ResponseWriter, instanceKey blob.Ref) {
	h.tplMu.RLock()
	defer h.tplMu.RUnlock()
	if err := h.tpl.ExecuteTemplate(w, "withform", &TemplateData{
		Prefix:      h.prefix,
		InstanceKey: instanceKey.String(),
		PiggyGIF:    h.piggyGIF,
	}); err != nil {
		h.logger.Printf("Could not serve progress: %v", err)
	}
}