github.com/NVIDIA/aistore@v1.3.23-0.20240517131212-7df6609be51d/xact/qui.go (about)

     1  // Package xact provides core functionality for the AIStore eXtended Actions (xactions).
     2  /*
     3   * Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
     4   */
     5  package xact
     6  
     7  import (
     8  	"time"
     9  
    10  	"github.com/NVIDIA/aistore/cmn/atomic"
    11  	"github.com/NVIDIA/aistore/core"
    12  )
    13  
    14  // common ref-counted quiescence
    15  func RefcntQuiCB(refc *atomic.Int32, maxTimeout, totalSoFar time.Duration) core.QuiRes {
    16  	if refc.Load() > 0 {
    17  		return core.QuiActive
    18  	}
    19  	if totalSoFar > maxTimeout {
    20  		return core.QuiTimeout
    21  	}
    22  	return core.QuiInactiveCB
    23  }