Skip to content

Commit

Permalink
bufferedReporting as requested
Browse files Browse the repository at this point in the history
  • Loading branch information
mkeskells committed Feb 15, 2018
1 parent 32bea17 commit 7c45bd8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Expand Up @@ -105,7 +105,7 @@ private[jvm] object GeneratedClassHandler {

final def postProcessUnit(unitInPostProcess: CompilationUnitInPostProcess): Unit = {
unitInPostProcess.task = Future {
frontendAccess.withThreadLocalReporter(unitInPostProcess) {
frontendAccess.withThreadLocalReporter(unitInPostProcess.bufferedReporting) {
// we 'take' classes to reduce the memory pressure
// as soon as the class is consumed and written, we release its data
unitInPostProcess.takeClasses() foreach {
Expand Down Expand Up @@ -149,7 +149,7 @@ private[jvm] object GeneratedClassHandler {
takeProcessingUnits().foreach { unitInPostProcess =>
try {
stealWhileWaiting(unitInPostProcess)
unitInPostProcess.relayReports(directBackendReporting)
unitInPostProcess.bufferedReporting.relayReports(directBackendReporting)
// We know the future is complete, throw the exception if it completed with a failure
unitInPostProcess.task.value.get.get
} catch {
Expand Down Expand Up @@ -200,7 +200,7 @@ sealed trait CompilationUnitPaths {
final class CompilationUnitInPostProcess(
private var classes: List[GeneratedClass],
val sourceFile: AbstractFile,
val outputDir: AbstractFile) extends CompilationUnitPaths with BufferingBackendReporting {
val outputDir: AbstractFile) extends CompilationUnitPaths {
def takeClasses(): List[GeneratedClass] = {
val c = classes
classes = Nil
Expand All @@ -209,4 +209,6 @@ final class CompilationUnitInPostProcess(

/** the main async task submitted onto the scheduler */
var task: Future[Unit] = _

val bufferedReporting = new BufferingBackendReporting
}
Expand Up @@ -89,7 +89,7 @@ object PostProcessorFrontendAccess {
def log(message: String): Unit
}

trait BufferingBackendReporting extends BackendReporting {
final class BufferingBackendReporting extends BackendReporting {
// We optimise access to the buffered reports for the common case - that there are no warning/errors to report
// We could use a listBuffer etc - but that would be extra allocation in the common case
// Note - all access is externally synchronized, as this allow the reports to be generated in on thread and
Expand Down

0 comments on commit 7c45bd8

Please sign in to comment.