mirror of https://github.com/sbt/sbt.git
Merge pull request #3999 from eed3si9n/wip/cache-watch-service
[bport] Cache watch service
This commit is contained in:
commit
3559de06aa
|
|
@ -94,7 +94,7 @@ object Watched {
|
|||
@tailrec def shouldTerminate: Boolean =
|
||||
(System.in.available > 0) && (watched.terminateWatch(System.in.read()) || shouldTerminate)
|
||||
val sources = watched.watchSources(s)
|
||||
val service = watched.watchService()
|
||||
val service = s get ContinuousWatchService getOrElse watched.watchService()
|
||||
val watchState = s get ContinuousState getOrElse WatchState.empty(service, sources)
|
||||
|
||||
if (watchState.count > 0)
|
||||
|
|
@ -115,15 +115,21 @@ object Watched {
|
|||
|
||||
if (triggered) {
|
||||
printIfDefined(watched triggeredMessage newWatchState)
|
||||
(ClearOnFailure :: next :: FailureWall :: repeat :: s).put(ContinuousState, newWatchState)
|
||||
(ClearOnFailure :: next :: FailureWall :: repeat :: s)
|
||||
.put(ContinuousState, newWatchState)
|
||||
.put(ContinuousWatchService, service)
|
||||
} else {
|
||||
while (System.in.available() > 0) System.in.read()
|
||||
service.close()
|
||||
s.remove(ContinuousState)
|
||||
s.remove(ContinuousState).remove(ContinuousWatchService)
|
||||
}
|
||||
}
|
||||
val ContinuousState =
|
||||
AttributeKey[WatchState]("watch state", "Internal: tracks state for continuous execution.")
|
||||
|
||||
val ContinuousWatchService =
|
||||
AttributeKey[WatchService]("watch service",
|
||||
"Internal: tracks watch service for continuous execution.")
|
||||
val Configuration =
|
||||
AttributeKey[Watched]("watched-configuration", "Configures continuous execution.")
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue