mirror of
https://github.com/ParkerTenBroeck/coroutines.git
synced 2026-06-07 05:08:51 -04:00
fixed generator code after changes to state machine builder
This commit is contained in:
parent
190c9814cf
commit
3a6ed0f81c
4 changed files with 82 additions and 100 deletions
|
|
@ -11,50 +11,10 @@ public class Main implements Runnable {
|
|||
|
||||
@Override
|
||||
public void run() {
|
||||
await();
|
||||
// lexer();
|
||||
// lambda();
|
||||
// await();
|
||||
lexer();
|
||||
}
|
||||
|
||||
// void lambda(){
|
||||
// var gen = ((Supplier<Gen<Integer, String>>)() -> {
|
||||
// Gen.yield(12);
|
||||
// return Gen.ret("hello");
|
||||
// }).get();
|
||||
//
|
||||
// while(true) {
|
||||
// var next = gen.next();
|
||||
// if(next instanceof Gen.Yield(var e)) System.out.println(e);
|
||||
// else if(next instanceof Gen.Ret(var ret)){
|
||||
// System.out.println(ret);
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
Object simple_async_rt(Future<?, RuntimeException> fut){
|
||||
final var waker = new Waker(){
|
||||
@Override
|
||||
public void wake() {
|
||||
synchronized (this){
|
||||
this.notifyAll();
|
||||
}
|
||||
}
|
||||
};
|
||||
while(true) {
|
||||
var next = fut.poll(waker);
|
||||
if(!(next instanceof Future.Pending)){
|
||||
return next;
|
||||
}
|
||||
System.out.println("Pending");
|
||||
synchronized (waker){
|
||||
try {
|
||||
waker.wait();
|
||||
} catch (InterruptedException ignore) {}
|
||||
}
|
||||
System.out.println("Woke");
|
||||
}
|
||||
}
|
||||
|
||||
void await(){
|
||||
new Jokio().blocking(AsyncExamples.test());
|
||||
|
|
@ -63,7 +23,6 @@ public class Main implements Runnable {
|
|||
|
||||
void lexer(){
|
||||
var gen = Lexer.parse("f7(x,y,z,w, u,v, othersIg) = v-(x*y+y+ln(z)^2*sin(z*pi/2))/(w*u)+sqrt(othersIg*120e-1)");
|
||||
// var gen = Examples.test(new double[]{1,2,3,4});
|
||||
while(gen.next() instanceof Gen.Yield(var tok)) {
|
||||
System.out.println(tok);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue