+/EE360P

distributed systems

git clone https://git.julia.blue/+/EE360P

vijaygarg1init99f4f39

master
425 B20 linesraw
1package clocks;
2public class LamportClock {
3    int c;
4    public LamportClock() {
5        c = 1;
6    }
7    public int getValue() {
8        return c;
9    }
10    public void tick() { // on internal events
11        c = c + 1;
12    }
13    public void sendAction() {
14       // include c in message
15        c = c + 1;      
16    }
17    public void receiveAction(int src, int sentValue) {
18        c = Math.max(c, sentValue) + 1;
19    }
20}