mirror of
https://github.com/ParkerTenBroeck/coroutines.git
synced 2026-06-07 05:08:51 -04:00
improved usability of cancellation annotations
This commit is contained in:
parent
baf0e86f39
commit
ce4dd70407
4 changed files with 133 additions and 98 deletions
|
|
@ -13,24 +13,32 @@ public class Main implements Runnable {
|
|||
RT.runWithGeneratorSupport(Main.class);
|
||||
}
|
||||
|
||||
class Meow implements AutoCloseable{
|
||||
{
|
||||
System.out.println("CREATED");
|
||||
}
|
||||
|
||||
static class Meow implements AutoCloseable{
|
||||
{System.out.println("CREATED");}
|
||||
@Override
|
||||
public void close() {
|
||||
System.out.println("CLOSED");
|
||||
}
|
||||
public static AutoCloseable test(){
|
||||
return new Meow();
|
||||
}
|
||||
}
|
||||
synchronized Future<Void, RuntimeException> nya(){
|
||||
|
||||
Future<Void, RuntimeException> nya(){
|
||||
try(@Cancellation("close") var nya = new Meow()){
|
||||
try(@Cancellation("close") var nya = Meow.test()){
|
||||
System.out.println("POLLED");
|
||||
Future.yield();
|
||||
System.out.println("POLLED");
|
||||
Future.yield();
|
||||
int beep = 1;
|
||||
System.out.println("POLLED");
|
||||
Future.yield();
|
||||
System.out.println("POLLED");
|
||||
Future.yield();
|
||||
return Future.ret(null);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue