mirror of
https://github.com/ParkerTenBroeck/coroutines.git
synced 2026-06-07 05:08:51 -04:00
fixed bug with saving stack
This commit is contained in:
parent
989c807aac
commit
90bfb8a631
5 changed files with 59 additions and 13 deletions
|
|
@ -2,6 +2,7 @@ import async_example.Delay;
|
|||
import async_example.Jokio;
|
||||
import async_example.Socket;
|
||||
import generator.future.Future;
|
||||
import generator.future.Waker;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
|
||||
|
|
@ -75,13 +76,17 @@ public class Examples {
|
|||
return Future.ret(number+"ms");
|
||||
}
|
||||
|
||||
public Future<String> awaitTest(int number){
|
||||
var result = awaitTest2(number).await();
|
||||
var rt = Jokio.runtime().await();
|
||||
rt.spawn(awaitTest2(5000));
|
||||
|
||||
closing(5000).await();
|
||||
return Future.ret("Result: " + result);
|
||||
public Future<Integer> number(int value){
|
||||
Waker.waker().wake();
|
||||
Future.yield();
|
||||
return Future.ret(value);
|
||||
}
|
||||
|
||||
public Future<String> awaitTest(int number){
|
||||
var result = number(10).await()+number(20).await();
|
||||
Jokio.runtime().await().spawn(awaitTest2(5000));
|
||||
return Future.ret(""+result);
|
||||
}
|
||||
|
||||
public Future<String> closing(int number){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue