mirror of
https://github.com/ParkerTenBroeck/coroutines.git
synced 2026-06-07 05:08:51 -04:00
added support for parameter cancellation
This commit is contained in:
parent
f0bc740e82
commit
051d5142d1
10 changed files with 154 additions and 64 deletions
|
|
@ -20,6 +20,14 @@ tasks.withType<JavaCompile> {
|
|||
options.compilerArgs.add("--enable-preview")
|
||||
}
|
||||
|
||||
tasks.register<JavaExec>("basic"){
|
||||
javaLauncher.set(javaToolchains.launcherFor(java.toolchain))
|
||||
jvmArgs("--enable-preview")
|
||||
group = "Demos"
|
||||
mainClass = "basic.Main"
|
||||
classpath = sourceSets["main"].runtimeClasspath
|
||||
}
|
||||
|
||||
tasks.register<JavaExec>("lexer"){
|
||||
javaLauncher.set(javaToolchains.launcherFor(java.toolchain))
|
||||
jvmArgs("--enable-preview")
|
||||
|
|
|
|||
7
app/src/main/java/basic/Futures.java
Normal file
7
app/src/main/java/basic/Futures.java
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
package basic;
|
||||
|
||||
import com.parkertenbroeck.future.Future;
|
||||
import com.parkertenbroeck.future.Waker;
|
||||
|
||||
public class Futures {
|
||||
}
|
||||
17
app/src/main/java/basic/Gens.java
Normal file
17
app/src/main/java/basic/Gens.java
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
package basic;
|
||||
|
||||
import com.parkertenbroeck.generator.Gen;
|
||||
|
||||
public class Gens {
|
||||
public static Gen<Long, Void> primes(){
|
||||
long number = 1;
|
||||
Gen.yield(2L);
|
||||
outer: while(true){
|
||||
number += 2;
|
||||
for(long i=2; i <= Math.sqrt(number); i ++){
|
||||
if(number%i==0)continue outer;
|
||||
}
|
||||
Gen.yield(number);
|
||||
}
|
||||
}
|
||||
}
|
||||
20
app/src/main/java/basic/Main.java
Normal file
20
app/src/main/java/basic/Main.java
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
package basic;
|
||||
|
||||
import com.parkertenbroeck.bcsm.RT;
|
||||
import com.parkertenbroeck.bcsm.loadtime.StateMachineClassLoader;
|
||||
import com.parkertenbroeck.generator.Gen;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
RT.runWithStateMachines(StateMachineClassLoader.Config.builtin().write_classes("build/modified/generators/"), (Object) args);
|
||||
|
||||
primes();
|
||||
}
|
||||
|
||||
static void primes(){
|
||||
var gen = Gens.primes();
|
||||
while(gen.next() instanceof Gen.Yield(var tok)) {
|
||||
System.out.println(tok);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -6,6 +6,7 @@ import com.parkertenbroeck.async_runtime.io.net.ServerSocket;
|
|||
import com.parkertenbroeck.async_runtime.io.net.Socket;
|
||||
import com.parkertenbroeck.future.Future;
|
||||
import com.parkertenbroeck.bcsm.loadtime.future.Cancellation;
|
||||
import com.parkertenbroeck.future.Waker;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue