Last active
August 29, 2015 14:06
-
-
Save RuedigerMoeller/10c583819616f2563969 to your computer and use it in GitHub Desktop.
emulation of scala's async macro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static void testRun(RLTable<TCRecord> table, TCMutator mutator, ClientActor client) { | |
async( | |
() -> mutator.$init(table), | |
() -> { | |
client.$run(table); | |
return mutator.$run(table, 1000, null); | |
}, | |
() -> table.$sync(), | |
() -> client.$unsubscribe(table), | |
() -> client.$checkCorrectness(table) | |
).then( (res, err) -> { | |
if (err == null) { | |
System.out.println("NEXT RUN"); | |
table.$sync(); | |
testRun(table, mutator, client); | |
} else { | |
System.out.println(err); | |
System.exit(1); | |
} | |
}); | |
} | |
// Same code with pure future chaining | |
private static void testRun(RLTable<TCRecord> table, TCMutator mutator, ClientActor client) { | |
mutator.$init(table).then(() -> { | |
client.$run(table); | |
mutator.$run(table, 1000, null).then( () -> | |
table.$sync().then( () -> | |
client.$unsubscribe(table).then( () -> | |
client.$checkCorrectness(table).then((res, err) -> { | |
if (err == null) { | |
System.out.println("NEXT RUN"); | |
table.$sync(); | |
testRun(table, mutator, client); | |
} else { | |
System.out.println(err); | |
System.exit(1); | |
} | |
}) | |
) | |
) | |
); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment