Created
April 19, 2012 17:58
-
-
Save viktorklang/2422659 to your computer and use it in GitHub Desktop.
Akka Futures in the Swing Event Dispatch Thread
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// © 2012 Viktor Klang | |
import akka.dispatch.ExecutionContext | |
import javax.swing.SwingUtilities | |
import java.util.concurrent.Executor | |
// | |
object SwingExecutionContext { | |
implicit val swingExecutionContext: ExecutionContext = ExecutionContext.fromExecutor(new Executor { | |
def execute(command: Runnable): Unit = SwingUtilities invokeLater command | |
}) | |
} | |
// Now all you need to do is to use it | |
import SwingExecutionContext._ | |
Future { | |
… | |
} | |
// Enjoy! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi!
Sorry for the late reply, just saw this.
I don't think it's needed to add to scala swing since it's just like 4 lines of code :-)
Cheers,
√