This commit is contained in:
ParkerTenBroeck 2025-04-26 15:37:40 -04:00
parent 7970df5ee3
commit 61b1ca1c12
6 changed files with 94 additions and 47 deletions

View file

@ -1,5 +1,6 @@
import generator.RT;
import generator.future.Future;
import generator.future.Waker;
import generator.gen.Gen;
import java.util.function.Supplier;
@ -32,24 +33,40 @@ public class Main implements Runnable {
// }
// }
void await(){
var gen = Examples.awaitTest(10);
Object simple_async_rt(Future<?> fut){
final var waker = new Waker(){
@Override
public void wake() {
synchronized (this){
this.notifyAll();
}
}
};
while(true) {
var next = (Object)gen.poll(() -> {});
var next = fut.poll(waker);
if(!(next instanceof Future.Pending)){
System.out.println(next);
break;
return next;
}
System.out.println("Pending");
synchronized (waker){
try {
waker.wait();
} catch (InterruptedException ignore) {}
}
System.out.println("Woke");
}
}
void await(){
System.out.println(simple_async_rt(new Examples().awaitTest(2000)));
}
// 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);
// }
// }
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);
}
}
}