Changeset 6178 for branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/Core.cs
- Timestamp:
- 05/10/11 17:58:59 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Slave/3.4/Core.cs
r6175 r6178 47 47 private Dictionary<Guid, Executor> executors = new Dictionary<Guid, Executor>(); 48 48 private Dictionary<Guid, AppDomain> appDomains = new Dictionary<Guid, AppDomain>(); 49 50 // signalizes if the Executor.Start method has properly finished. only then the appdomain may be unloaded 51 private Dictionary<Guid, Semaphore> semaphores = new Dictionary<Guid, Semaphore>(); 49 52 50 53 private WcfService wcfService; … … 484 487 executor.MemoryNeeded = job.MemoryNeeded; 485 488 clientCom.LogMessage("Starting Executor for job " + job.Id); 486 executor.Start(jobData.Data);487 489 lock (executors) { 488 490 executors.Add(job.Id, executor); 489 491 } 492 semaphores[job.Id] = new Semaphore(0, 1); 493 executor.Start(jobData.Data); 494 semaphores[job.Id].Release(); 490 495 } 491 496 catch (Exception exception) { … … 535 540 /// Kill a appdomain with a specific id. 536 541 /// </summary> 537 /// <param name=" id">the GUID of the job</param>538 public void KillAppDomain(Guid id) {542 /// <param name="jobId">the GUID of the job</param> 543 public void KillAppDomain(Guid jobId) { 539 544 if (Thread.CurrentThread.ManagedThreadId != this.coreThreadId) { 540 EnqueueExecutorMessage<Guid>(KillAppDomain, id);545 EnqueueExecutorMessage<Guid>(KillAppDomain, jobId); 541 546 return; 542 547 } 543 548 544 clientCom.LogMessage("Shutting down Appdomain for Job " + id);549 clientCom.LogMessage("Shutting down Appdomain for Job " + jobId); 545 550 lock (executors) { 546 551 try { 547 if (executors.ContainsKey(id)) { 548 executors[id].Dispose(); 549 executors.Remove(id); 550 } 551 552 if (appDomains.ContainsKey(id)) { 553 appDomains[id].UnhandledException -= new UnhandledExceptionEventHandler(AppDomain_UnhandledException); 554 552 if (executors.ContainsKey(jobId)) { 553 executors[jobId].Dispose(); 554 executors.Remove(jobId); 555 } 556 557 if (appDomains.ContainsKey(jobId)) { 558 appDomains[jobId].UnhandledException -= new UnhandledExceptionEventHandler(AppDomain_UnhandledException); 555 559 int repeat = 5; 556 560 while (repeat > 0) { 557 561 try { 558 AppDomain.Unload(appDomains[id]); 562 semaphores[jobId].WaitOne(); 563 AppDomain.Unload(appDomains[jobId]); 564 semaphores[jobId].Dispose(); 565 semaphores.Remove(jobId); 559 566 repeat = 0; 560 567 } … … 569 576 } 570 577 } 571 appDomains.Remove( id);572 } 573 574 PluginCache.Instance.DeletePluginsForJob( id);578 appDomains.Remove(jobId); 579 } 580 581 PluginCache.Instance.DeletePluginsForJob(jobId); 575 582 GC.Collect(); 576 583 }
Note: See TracChangeset
for help on using the changeset viewer.