- Timestamp:
- 06/28/16 17:03:36 (8 years ago)
- Location:
- branches/thasling/DistributedGA/DistributedGA.ContactServer
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/thasling/DistributedGA/DistributedGA.ContactServer/ContactServiceImpl.cs
r13924 r13943 18 18 19 19 private Object logLock = new Object(); 20 21 private Object timerLock = new Object();//if elapsed takes too long, another thread also enters the method 20 22 21 23 public ContactServiceImpl() { … … 78 80 79 81 private void CleanUpContactTable(object sender, ElapsedEventArgs e) { 80 DateTime deadline = DateTime.Now; 81 //collect items to remove 82 List<PeerInfo> itemsToDelete = new List<PeerInfo>(); 83 foreach (PeerInfo pi in allPeers.Keys) { 84 DateTime tmp; 85 if (allPeers.TryGetValue(pi, out tmp)) { 86 //if (tmp.AddHours(1f) < deadline) 87 if (tmp.AddMinutes(1) < deadline) //TODO 82 lock (timerLock) { 83 DateTime deadline = DateTime.Now; 84 //collect items to remove 85 List<PeerInfo> itemsToDelete = new List<PeerInfo>(); 86 foreach (PeerInfo pi in allPeers.Keys) { 87 DateTime tmp; 88 if (allPeers.TryGetValue(pi, out tmp)) { 89 //if (tmp.AddHours(1f) < deadline) 90 if (tmp.AddMinutes(1) < deadline) //TODO 88 91 { 89 //if (tmp < deadline.AddHours(1f)) { 90 itemsToDelete.Add(pi); 92 //if (tmp < deadline.AddHours(1f)) { 93 itemsToDelete.Add(pi); 94 } 91 95 } 92 96 } 93 }94 //remove items95 foreach (PeerInfo pi in itemsToDelete) {96 DateTime tmp;97 allPeers.TryRemove(pi, out tmp);98 Console.WriteLine(string.Format("Removed peer {0}:{1} from dictionary because last access was: {2}", pi.IpAddress, pi.Port, tmp));97 //remove items 98 foreach (PeerInfo pi in itemsToDelete) { 99 DateTime tmp; 100 allPeers.TryRemove(pi, out tmp); 101 Console.WriteLine(string.Format("Removed peer {0}:{1} from dictionary because last access was: {2}", pi.IpAddress, pi.Port, tmp)); 102 } 99 103 } 100 104 } -
branches/thasling/DistributedGA/DistributedGA.ContactServer/DistributedGA.ContactServer.csproj
r13524 r13943 55 55 </ItemGroup> 56 56 <ItemGroup> 57 <None Include="App.config" /> 57 <None Include="App.config"> 58 <SubType>Designer</SubType> 59 </None> 58 60 </ItemGroup> 59 61 <ItemGroup>
Note: See TracChangeset
for help on using the changeset viewer.