Last active
March 16, 2020 04:20
-
-
Save retronym/c219f8759bd92b8f65804fbaeffcb6ec to your computer and use it in GitHub Desktop.
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
import scala.concurrent._, duration.Duration, ExecutionContext.Implicits.global | |
import scala.async.Async.{async, await} | |
object Test { | |
def test: Future[Int] = async { await(f(1)) + await(f(2)) } | |
def f(x: Int): Future[Int] = Future.successful(x) | |
} |
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
<method> def apply(tr$async: util.this.Try): scala.this.Unit = while$(){ | |
try { | |
Test$stateMachine$async$1.this.state$async() match { | |
case 0 => { | |
val awaitable$async: concurrent.this.Future = Test.this.f(1); | |
tr$async = if (awaitable$async.isCompleted()) | |
awaitable$async.value().get().$asInstanceOf[util.this.Try]() | |
else | |
null; | |
Test$stateMachine$async$1.this.state$async_$eq(1); | |
if (null.ne(tr$async)) | |
while$() | |
else | |
{ | |
awaitable$async.onComplete(this, Test$stateMachine$async$1.this.execContext$async()); | |
return () | |
} | |
} | |
case 1 => { | |
Test$stateMachine$async$1.this.await$async$0 = null; | |
if (tr$async.isFailure()) | |
{ | |
Test$stateMachine$async$1.this.result$async().complete(tr$async); | |
return () | |
} | |
else | |
Test$stateMachine$async$1.this.await$async$0 = tr$async.get(); | |
val awaitable$async: concurrent.this.Future = Test.this.f(2); | |
tr$async = if (awaitable$async.isCompleted()) | |
awaitable$async.value().get().$asInstanceOf[util.this.Try]() | |
else | |
null; | |
Test$stateMachine$async$1.this.state$async_$eq(2); | |
if (null.ne(tr$async)) | |
while$() | |
else | |
{ | |
awaitable$async.onComplete(this, Test$stateMachine$async$1.this.execContext$async()); | |
return () | |
} | |
} | |
case 2 => { | |
<mutable> <synthetic> var await$async$1: lang.this.Object = null; | |
if (tr$async.isFailure()) | |
{ | |
Test$stateMachine$async$1.this.result$async().complete(tr$async); | |
return () | |
} | |
else | |
await$async$1 = tr$async.get(); | |
<synthetic> val x$async$1: scala.this.Int = scala.Int.unbox(await$async$1); | |
Test$stateMachine$async$1.this.result$async().complete(new util.Success.<init>(scala.Int.box(scala.Int.unbox(Test$stateMachine$async$1.this.await$async$0).$plus(x$async$1)))); | |
return (); | |
Test$stateMachine$async$1.this.await$async$0 = null | |
} | |
case _ => throw new IllegalStateException.<init>(java.lang.String.valueOf(Test$stateMachine$async$1.this.state$async())) | |
} | |
} catch { | |
case (throwable$async @ (_: Throwable)) => { | |
Test$stateMachine$async$1.this.result$async().complete(new util.Failure.<init>(throwable$async)); | |
return () | |
} | |
}; | |
while$() | |
}; |
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
<method> def apply(tr$async: util.this.Try): scala.this.Unit = while$(){ | |
try { | |
if (null.ne(tr$async)) | |
if (tr$async.isFailure()) | |
{ | |
Test$stateMachine$async$1.this.result$async().complete(tr$async); | |
return () | |
} | |
else | |
() | |
else | |
(); | |
Test$stateMachine$async$1.this.state$async() match { | |
case 0 => { | |
val awaitable$async: concurrent.this.Future = Test.this.f(1); | |
await(awaitable$async, 1) | |
} | |
case 1 => { | |
Test$stateMachine$async$1.this.await$async$0 = tr$async.get(); | |
val awaitable$async: concurrent.this.Future = Test.this.f(2); | |
await(awaitable$async, 2) | |
} | |
case 2 => { | |
<synthetic> val await$async$1: lang.this.Object = tr$async.get(); | |
<synthetic> val x$async$1: scala.this.Int = scala.Int.unbox(await$async$1); | |
Test$stateMachine$async$1.this.result$async().complete(new util.Success.<init>(scala.Int.box(scala.Int.unbox(Test$stateMachine$async$1.this.await$async$0).$plus(x$async$1)))); | |
return () | |
} | |
case _ => throw new IllegalStateException.<init>(java.lang.String.valueOf(Test$stateMachine$async$1.this.state$async())) | |
} | |
} catch { | |
case (throwable$async @ (_: Throwable)) => { | |
Test$stateMachine$async$1.this.result$async().complete(new util.Failure.<init>(throwable$async)); | |
return () | |
} | |
}; | |
while$(); | |
await(x: concurrent.this.Future, state: scala.this.Int){ | |
tr$async = if (x.isCompleted()) | |
x.value().get().$asInstanceOf[util.this.Try]() | |
else | |
null; | |
Test$stateMachine$async$1.this.state$async_$eq(state); | |
if (null.ne(tr$async)) | |
while$() | |
else | |
{ | |
x.onComplete(this, Test$stateMachine$async$1.this.execContext$async()); | |
return () | |
} | |
} | |
}; |
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
@@ -1,65 +1,52 @@ | |
<method> def apply(tr$async: util.this.Try): scala.this.Unit = while$(){ | |
try { | |
+ if (null.ne(tr$async)) | |
+ if (tr$async.isFailure()) | |
+ { | |
+ Test$stateMachine$async$1.this.result$async().complete(tr$async); | |
+ return () | |
+ } | |
+ else | |
+ () | |
+ else | |
+ (); | |
Test$stateMachine$async$1.this.state$async() match { | |
case 0 => { | |
val awaitable$async: concurrent.this.Future = Test.this.f(1); | |
- tr$async = if (awaitable$async.isCompleted()) | |
- awaitable$async.value().get().$asInstanceOf[util.this.Try]() | |
- else | |
- null; | |
- Test$stateMachine$async$1.this.state$async_$eq(1); | |
- if (null.ne(tr$async)) | |
- while$() | |
- else | |
- { | |
- awaitable$async.onComplete(this, Test$stateMachine$async$1.this.execContext$async()); | |
- return () | |
- } | |
+ await(awaitable$async, 1) | |
} | |
case 1 => { | |
- Test$stateMachine$async$1.this.await$async$0 = null; | |
- if (tr$async.isFailure()) | |
- { | |
- Test$stateMachine$async$1.this.result$async().complete(tr$async); | |
- return () | |
- } | |
- else | |
- Test$stateMachine$async$1.this.await$async$0 = tr$async.get(); | |
+ Test$stateMachine$async$1.this.await$async$0 = tr$async.get(); | |
val awaitable$async: concurrent.this.Future = Test.this.f(2); | |
- tr$async = if (awaitable$async.isCompleted()) | |
- awaitable$async.value().get().$asInstanceOf[util.this.Try]() | |
- else | |
- null; | |
- Test$stateMachine$async$1.this.state$async_$eq(2); | |
- if (null.ne(tr$async)) | |
- while$() | |
- else | |
- { | |
- awaitable$async.onComplete(this, Test$stateMachine$async$1.this.execContext$async()); | |
- return () | |
- } | |
+ await(awaitable$async, 2) | |
} | |
case 2 => { | |
- <mutable> <synthetic> var await$async$1: lang.this.Object = null; | |
- if (tr$async.isFailure()) | |
- { | |
- Test$stateMachine$async$1.this.result$async().complete(tr$async); | |
- return () | |
- } | |
- else | |
- await$async$1 = tr$async.get(); | |
+ <synthetic> val await$async$1: lang.this.Object = tr$async.get(); | |
<synthetic> val x$async$1: scala.this.Int = scala.Int.unbox(await$async$1); | |
Test$stateMachine$async$1.this.result$async().complete(new util.Success.<init>(scala.Int.box(scala.Int.unbox(Test$stateMachine$async$1.this.await$async$0).$plus(x$async$1)))); | |
- return (); | |
- Test$stateMachine$async$1.this.await$async$0 = null | |
+ return () | |
} | |
case _ => throw new IllegalStateException.<init>(java.lang.String.valueOf(Test$stateMachine$async$1.this.state$async())) | |
} | |
} catch { | |
case (throwable$async @ (_: Throwable)) => { | |
Test$stateMachine$async$1.this.result$async().complete(new util.Failure.<init>(throwable$async)); | |
return () | |
} | |
}; | |
- while$() | |
- }; | |
+ while$(); | |
+ await(x: concurrent.this.Future, state: scala.this.Int){ | |
+ tr$async = if (x.isCompleted()) | |
+ x.value().get().$asInstanceOf[util.this.Try]() | |
+ else | |
+ null; | |
+ Test$stateMachine$async$1.this.state$async_$eq(state); | |
+ if (null.ne(tr$async)) | |
+ while$() | |
+ else | |
+ { | |
+ x.onComplete(this, Test$stateMachine$async$1.this.execContext$async()); | |
+ return () | |
+ } | |
+ } | |
+ }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment