2010-06-27 15:18:35 +02:00
|
|
|
/* sbt -- Simple Build Tool
|
|
|
|
|
* Copyright 2010 Mark Harrah
|
|
|
|
|
*/
|
|
|
|
|
package sbt
|
|
|
|
|
package inc
|
|
|
|
|
|
|
|
|
|
trait AnalysisStore
|
|
|
|
|
{
|
|
|
|
|
def set(analysis: Analysis, setup: CompileSetup): Unit
|
2010-07-02 12:57:03 +02:00
|
|
|
def get(): Option[(Analysis, CompileSetup)]
|
2010-06-27 15:18:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
object AnalysisStore
|
|
|
|
|
{
|
|
|
|
|
def cached(backing: AnalysisStore): AnalysisStore = new AnalysisStore {
|
|
|
|
|
private var last: Option[(Analysis, CompileSetup)] = None
|
|
|
|
|
def set(analysis: Analysis, setup: CompileSetup)
|
|
|
|
|
{
|
|
|
|
|
backing.set(analysis, setup)
|
|
|
|
|
last = Some( (analysis, setup) )
|
|
|
|
|
}
|
2010-07-02 12:57:03 +02:00
|
|
|
def get(): Option[(Analysis, CompileSetup)] =
|
2010-06-27 15:18:35 +02:00
|
|
|
{
|
|
|
|
|
if(last.isEmpty)
|
2010-07-02 12:57:03 +02:00
|
|
|
last = backing.get()
|
|
|
|
|
last
|
2010-06-27 15:18:35 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
def sync(backing: AnalysisStore): AnalysisStore = new AnalysisStore {
|
|
|
|
|
def set(analysis: Analysis, setup: CompileSetup): Unit = synchronized { backing.set(analysis, setup) }
|
2010-07-02 12:57:03 +02:00
|
|
|
def get(): Option[(Analysis, CompileSetup)] = synchronized { backing.get() }
|
2010-06-27 15:18:35 +02:00
|
|
|
}
|
|
|
|
|
}
|