Changeset 141 for MicroThreading/UMicroThreading.pas
- Timestamp:
- Jan 24, 2011, 8:49:56 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
MicroThreading/UMicroThreading.pas
r140 r141 9 9 {$IFDEF Windows}Windows,{$ENDIF} 10 10 {$IFDEF Linux}BaseUnix, UnixUtil, Unix,{$ENDIF} 11 Classes, SysUtils, Contnrs, SyncObjs, DateUtils, Dialogs ;11 Classes, SysUtils, Contnrs, SyncObjs, DateUtils, Dialogs, Forms; 12 12 13 13 type … … 66 66 FExecuteCount: Integer; 67 67 FExecutedCount: Integer; 68 FTerminated: Boolean; 68 69 function GetMicroThreadCount: Integer; 69 70 procedure Yield(MicroThread: TMicroThread); … … 76 77 destructor Destroy; override; 77 78 function Execute(Count: Integer): Integer; 79 procedure Start; 80 procedure Stop; 78 81 property MicroThreadCount: Integer read GetMicroThreadCount; 79 82 property FreeMicroThreadOnFinish: Boolean read FFreeMicroThreadOnFinish … … 167 170 destructor TMicroThreadScheduler.Destroy; 168 171 begin 172 FTerminated := True; 169 173 ThreadPool.Free; 170 174 MicroThreads.Free; … … 179 183 Yield(nil); 180 184 Result := FExecutedCount; 185 end; 186 187 procedure TMicroThreadScheduler.Start; 188 var 189 Executed: Integer; 190 begin 191 FTerminated := False; 192 repeat 193 Executed := Execute(10); 194 Application.ProcessMessages; 195 if Executed = 0 then Sleep(1); 196 until FTerminated; 197 end; 198 199 procedure TMicroThreadScheduler.Stop; 200 begin 201 FTerminated := True; 181 202 end; 182 203
Note:
See TracChangeset
for help on using the changeset viewer.