コード例 #1
0
 public ExtendedLamportClockObject(long id, int logicalClock) //this used for when we want to make an instance from another machines
 {
     this.id           = id;
     this.logicalClock = logicalClock;
     //Now correct the clock
     //LC = Max(LC, LCsender) + 1
     //if the remote machine has a Logical Clock that is less than this machine clock
     if (this.logicalClock < LogicalClock.getLogicalClock())
     {
         LogicalClock.nextLogicalClock(); //it will increase the logical clock by 1 unit [LC = LC + 1]
     }
     else //if the remote machine has a Logical Clock that is greater than this machine clock
     {
         LogicalClock.setLogicalClock(logicalClock + 1); //LC = LCsender + 1
     }
 }
コード例 #2
0
 public ExtendedLamportClockObject() //this used for when we want to make an instance for this machine
 {
     this.id           = MachinIdentification.getUniqueIdNumber();
     this.logicalClock = LogicalClock.nextLogicalClock();
 }