mirror of https://github.com/sbt/sbt.git
Don't lock threads when user has specified COURSIER_PROGRESS=disable or otherwise disabled progress bars (#273)
This commit is contained in:
parent
f80641a221
commit
c7d20763d2
|
|
@ -24,11 +24,6 @@ object ArtifactsRun {
|
|||
else
|
||||
""
|
||||
|
||||
// Ensuring only one resolution / artifact fetching runs at a time when the logger
|
||||
// may rely on progress bars, as two progress bar loggers can't display stuff at the
|
||||
// same time.
|
||||
val needsLock = params.loggerOpt.nonEmpty || !RefreshLogger.defaultFallbackMode
|
||||
|
||||
val coursierLogger = params.loggerOpt.getOrElse {
|
||||
RefreshLogger.create(
|
||||
if (RefreshLogger.defaultFallbackMode)
|
||||
|
|
@ -45,12 +40,9 @@ object ArtifactsRun {
|
|||
)
|
||||
}
|
||||
|
||||
if (needsLock)
|
||||
Lock.lock.synchronized {
|
||||
result(params, coursierLogger)
|
||||
}
|
||||
else
|
||||
Lock.maybeSynchronized(needsLock = params.loggerOpt.nonEmpty || !RefreshLogger.defaultFallbackMode){
|
||||
result(params, coursierLogger)
|
||||
}
|
||||
}
|
||||
|
||||
private def result(
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
package lmcoursier.internal
|
||||
|
||||
private[lmcoursier] object Lock {
|
||||
private val lock = new Object
|
||||
|
||||
// Wrap blocks downloading stuff (resolution / artifact downloads) in lock.synchronized.
|
||||
// Downloads are already parallel, no need to parallelize further, and this results in
|
||||
// a clearer output.
|
||||
val lock = new Object
|
||||
|
||||
/* Progress bars require us to only work on one module at the time. Without those we can go faster */
|
||||
def maybeSynchronized[T](needsLock: Boolean)(f: => T): T =
|
||||
if (needsLock) lock.synchronized(f)
|
||||
else f
|
||||
}
|
||||
|
|
|
|||
|
|
@ -137,10 +137,8 @@ object ResolutionRun {
|
|||
}
|
||||
|
||||
SbtCoursierCache.default.resolutionOpt(params.resolutionKey).map(Right(_)).getOrElse {
|
||||
// Let's update only one module at once, for a better output.
|
||||
// Downloads are already parallel, no need to parallelize further, anyway.
|
||||
val resOrError =
|
||||
Lock.lock.synchronized {
|
||||
Lock.maybeSynchronized(needsLock = params.loggerOpt.nonEmpty || !RefreshLogger.defaultFallbackMode) {
|
||||
var map = new mutable.HashMap[Configuration, Resolution]
|
||||
val either = params.orderedConfigs.foldLeft[Either[coursier.error.ResolutionError, Unit]](Right(())) {
|
||||
case (acc, (config, extends0)) =>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package lmcoursier.internal
|
||||
|
||||
import coursier.cache.loggers.RefreshLogger
|
||||
import coursier.core.Resolution.ModuleVersion
|
||||
import coursier.core._
|
||||
import coursier.util.Print
|
||||
|
|
@ -55,8 +56,7 @@ object UpdateRun {
|
|||
params: UpdateParams,
|
||||
verbosityLevel: Int,
|
||||
log: Logger
|
||||
): UpdateReport = Lock.lock.synchronized {
|
||||
|
||||
): UpdateReport = Lock.maybeSynchronized(needsLock = !RefreshLogger.defaultFallbackMode) {
|
||||
val depsByConfig = grouped(params.dependencies)
|
||||
|
||||
if (verbosityLevel >= 2) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue