Skip to content

Instantly share code, notes, and snippets.

@yufan-liu
Created June 12, 2014 03:27
Show Gist options
  • Save yufan-liu/ef8486edee3bc4bced89 to your computer and use it in GitHub Desktop.
Save yufan-liu/ef8486edee3bc4bced89 to your computer and use it in GitHub Desktop.
Spark event dispatcher.
// version spark 1.0.0
// file org.apache.spark.scheduler.LiveListenerBus
private val listenerThread = new Thread("SparkListenerBus") {
setDaemon(true)
override def run(): Unit = Utils.logUncaughtExceptions {
while (true) {
eventLock.acquire()
// Atomically remove and process this event
LiveListenerBus.this.synchronized {
val event = eventQueue.poll
if (event == SparkListenerShutdown) {
// Get out of the while loop and shutdown the daemon thread
return
}
Option(event).foreach(postToAll)
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment