+/EE360P
distributed systems
git clone https://git.julia.blue/+/EE360P
99f4f39
master
1package clocks ; 2public class DirectClock { 3public int []clock ; 4int myId ; 5public DirectClock (int numProc ,int id ) { 6myId =id ; 7clock =new int [numProc ]; 8for (int i =0 ;i <numProc ;i ++)clock [i ] =0 ; 9clock [myId ] =1 ; 10 } 11public int getValue (int i ) { 12return clock [i ]; 13 } 14public void tick () { 15clock [myId ]++; 16 } 17public void sendAction () { 18// sentValue = clock[myId]; 19tick (); 20 } 21public void receiveAction (int sender ,int sentValue ) { 22clock [sender ] =Math .max (clock [sender ],sentValue ); 23clock [myId ] =Math .max (clock [myId ],sentValue ) +1 ; 24 } 25} 26