Replacing callable and rullable funs with SAM constructor

This commit is contained in:
Mikhael Bogdanov
2013-12-02 16:24:30 +04:00
parent 1dba69186c
commit 0e0f950140
2 changed files with 2 additions and 15 deletions
@@ -42,6 +42,7 @@ public inline fun Throwable.printStackTrace(stream: PrintStream): Unit {
/**
* A helper method for creating a [[Callable]] from a function
*/
deprecated("Use SAM constructor: Callable(...)")
public /*inline*/ fun <T> callable(action: ()-> T): Callable<T> {
return object: Callable<T> {
public override fun call() = action()
@@ -51,6 +52,7 @@ public /*inline*/ fun <T> callable(action: ()-> T): Callable<T> {
/**
* A helper method for creating a [[Runnable]] from a function
*/
deprecated("Use SAM constructor: Runnable(...)")
public /*inline*/ fun runnable(action: ()-> Unit): Runnable {
return object: Runnable {
public override fun run() {
@@ -46,13 +46,6 @@ public fun thread(start: Boolean = true, daemon: Boolean = false, contextClassLo
return thread
}
/**
* Executes the given block on the [[Executor]]
*/
public /*inline*/ fun Executor.execute(action: ()->Unit) {
execute(runnable(action))
}
/**
* Allows you to use the executor as a function to
* execute the given block on the [[Executor]].
@@ -61,14 +54,6 @@ public /*inline*/ fun Executor.invoke(action: ()->Unit) {
execute(runnable(action))
}
/**
* Executes the given block on the [[Executor]]
*/
public /*inline*/ fun <T>ExecutorService.submit(action: ()->T):Future<T> {
val c:Callable<T> = callable(action)
return submit(c);
}
/**
* Allows you to use the executor as a function to
* execute the given block on the [[Executor]].