Ignore:
Timestamp:
Jan 26, 2011, 7:28:29 AM (14 years ago)
Author:
george
Message:
  • Fixed: Freeing micro threads on finish.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • MicroThreading/UMicroThreading.pas

    r145 r146  
    4545    Manager: TMicroThreadManager;
    4646    Scheduler: TMicroThreadScheduler;
     47    Completion: Single; // Can be used for progress information in range <0, 1>
    4748    procedure Execute; virtual;
    4849
     
    247248        mov edx, [eax].TMicroThread.FStackPointer
    248249        mov esp, edx
     250        push ebp
    249251        mov edx, [eax].TMicroThread.FBasePointer
    250252        mov ebp, edx
    251253      end;
    252254      StaticMicroThread.Execute;
     255      asm
     256        pop ebp
     257      end;
    253258      //FSelected.Method(FSelected);
    254       StaticManager := StaticMicroThread.Manager;
     259      StaticManager := CurrentMicroThread.Manager;
    255260      asm
    256261        // Restore scheduler stack
     
    267272      CurrentMicroThread.FFinished := True;
    268273      if CurrentMicroThread.FFreeOnTerminate then begin
    269         CurrentMicroThread.Free;
     274        // Microthread is finished, remove it from queue
     275        with Scheduler do
     276        try
     277          Lock.Acquire;
     278          MicroThreads.Delete(MicroThreads.IndexOf(CurrentMicroThread));
     279        finally
     280          Lock.Release;
     281        end;
    270282      end;
    271283      CurrentMicroThread := nil;
     
    387399destructor TMicroThread.Destroy;
    388400begin
    389   Terminate;
    390   WaitFor;
    391   // Microthread is finished, remove it from queue
    392   try
    393     Manager.Scheduler.Lock.Acquire;
    394     Manager.Scheduler.MicroThreads.Delete(Manager.Scheduler.MicroThreads.IndexOf(Self));
    395   finally
    396     Manager.Scheduler.Lock.Release;
    397   end;
     401  //Terminate;
     402  //WaitFor;
    398403  FreeMem(FStack);
    399404  inherited Destroy;
Note: See TracChangeset for help on using the changeset viewer.