This file contains hidden or 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
| abstract class ByteStream { .. } | |
| class SomeClass { | |
| void someMethod() { | |
| this.getStream().writeByte(13); // call on interface or abstract class | |
| } | |
| ByteStream getStream() { .. } | |
| } | |
| // later in code |
This file contains hidden or 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
| public class KontrActorPi { | |
| public static class PiActor extends Actor<PiActor> { | |
| public void $calculatePiFor(int start, int nrOfElements, Adder adder) { | |
| double acc = 0.0; | |
| for (int i = start * nrOfElements; i <= ((start + 1) * nrOfElements - 1); i++) { | |
| acc += 4.0 * (1 - (i % 2) * 2) / (2 * i + 1); | |
| } | |
| adder.$add(acc); | |
| } |
This file contains hidden or 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
| exec( () -> { | |
| try { | |
| return new Promise(new URL("http://www.google.com").getContent()); | |
| } catch (IOException e) { | |
| return new Promise(null, e); | |
| } | |
| }).then( (content, error) -> { | |
| // handle result | |
| }); |
This file contains hidden or 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) |
This file contains hidden or 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
| public class DisruptorTest2 { | |
| public static class PiJob { | |
| public double result; | |
| public int sliceNr; | |
| public int numIter; | |
| public int partionId; | |
| public void calculatePi() { | |
| double acc = 0.0; |
This file contains hidden or 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
| public class DisruptorTest { | |
| public static class PiJob { | |
| public double result; | |
| public int sliceNr; | |
| public int numIter; | |
| public void calculatePi() { | |
| double acc = 0.0; | |
| for (int i = sliceNr * numIter; i <= ((sliceNr + 1) * numIter - 1); i++) { |
This file contains hidden or 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
| public class DisruptorTest { | |
| public static class PiJob { | |
| public double result; | |
| public int sliceNr; | |
| public int numIter; | |
| public void calculatePi() { | |
| double acc = 0.0; | |
| for (int i = sliceNr * numIter; i <= ((sliceNr + 1) * numIter - 1); i++) { |
This file contains hidden or 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
| public class ActorPiSample { | |
| public static class PiActor extends Actor { | |
| public void calculatePiFor(int start, int nrOfElements, ChannelActor result ) { | |
| double acc = 0.0; | |
| for (int i = start * nrOfElements; i <= ((start + 1) * nrOfElements - 1); i++) { | |
| acc += 4.0 * (1 - (i % 2) * 2) / (2 * i + 1); | |
| } | |
| result.receiveResult(acc); | |
| } |
This file contains hidden or 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
| public class ThreadPi { | |
| static double calculatePiFor(int slice, int nrOfIterations) { | |
| double acc = 0.0; | |
| for (int i = slice * nrOfIterations; i <= ((slice + 1) * nrOfIterations - 1); i++) { | |
| acc += 4.0 * (1 - (i % 2) * 2) / (2 * i + 1); | |
| } | |
| return acc; | |
| } |
This file contains hidden or 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
| static double calculatePiFor(int slice, int nrOfIterations) { | |
| double acc = 0.0; | |
| for (int i = slice * nrOfIterations; i <= ((slice + 1) * nrOfIterations - 1); i++) { | |
| acc += 4.0 * (1 - (i % 2) * 2) / (2 * i + 1); | |
| } | |
| return acc; | |
| } |
NewerOlder