Changeset 146 for MicroThreading/UMicroThreading.pas
- Timestamp:
- Jan 26, 2011, 7:28:29 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
MicroThreading/UMicroThreading.pas
r145 r146 45 45 Manager: TMicroThreadManager; 46 46 Scheduler: TMicroThreadScheduler; 47 Completion: Single; // Can be used for progress information in range <0, 1> 47 48 procedure Execute; virtual; 48 49 … … 247 248 mov edx, [eax].TMicroThread.FStackPointer 248 249 mov esp, edx 250 push ebp 249 251 mov edx, [eax].TMicroThread.FBasePointer 250 252 mov ebp, edx 251 253 end; 252 254 StaticMicroThread.Execute; 255 asm 256 pop ebp 257 end; 253 258 //FSelected.Method(FSelected); 254 StaticManager := StaticMicroThread.Manager;259 StaticManager := CurrentMicroThread.Manager; 255 260 asm 256 261 // Restore scheduler stack … … 267 272 CurrentMicroThread.FFinished := True; 268 273 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; 270 282 end; 271 283 CurrentMicroThread := nil; … … 387 399 destructor TMicroThread.Destroy; 388 400 begin 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; 398 403 FreeMem(FStack); 399 404 inherited Destroy;
Note:
See TracChangeset
for help on using the changeset viewer.